diff options
author | vjpai <vpai@google.com> | 2015-09-24 17:55:18 -0700 |
---|---|---|
committer | vjpai <vpai@google.com> | 2015-09-24 17:55:18 -0700 |
commit | 9839d285cd39d3fd2a16f3393f33e72f1e6b645b (patch) | |
tree | 636d1e349d23d4361d2313539a9324888b6e46c7 /src/core/support | |
parent | 50d653476d4d49978ee3586b1b46b0f247eb60e5 (diff) |
Move block_annotate from iomgr to support since it's used in other
core places besides iomgr
Diffstat (limited to 'src/core/support')
-rw-r--r-- | src/core/support/block_annotate.h | 44 | ||||
-rw-r--r-- | src/core/support/file.c | 6 | ||||
-rw-r--r-- | src/core/support/time_posix.c | 6 | ||||
-rw-r--r-- | src/core/support/time_win32.c | 6 |
4 files changed, 53 insertions, 9 deletions
diff --git a/src/core/support/block_annotate.h b/src/core/support/block_annotate.h new file mode 100644 index 0000000000..bf2c17f859 --- /dev/null +++ b/src/core/support/block_annotate.h @@ -0,0 +1,44 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_INTERNAL_CORE_SUPPORT_BLOCK_ANNOTATE_H +#define GRPC_INTERNAL_CORE_SUPPORT_BLOCK_ANNOTATE_H + +/* These annotations identify the beginning and end of regions where + the code may block for reasons other than synchronization functions. + These include poll, epoll, and getaddrinfo. */ + +#define GRPC_SCHEDULING_START_BLOCKING_REGION do {} while (0) +#define GRPC_SCHEDULING_END_BLOCKING_REGION do {} while (0) + +#endif /* GRPC_INTERNAL_CORE_SUPPORT_BLOCK_ANNOTATE_H */ diff --git a/src/core/support/file.c b/src/core/support/file.c index 25a566905e..8c673dbcc6 100644 --- a/src/core/support/file.c +++ b/src/core/support/file.c @@ -40,7 +40,7 @@ #include <grpc/support/log.h> #include <grpc/support/string_util.h> -#include "src/core/iomgr/block_annotate.h" +#include "src/core/support/block_annotate.h" #include "src/core/support/string.h" gpr_slice gpr_load_file(const char *filename, int add_null_terminator, @@ -52,7 +52,7 @@ gpr_slice gpr_load_file(const char *filename, int add_null_terminator, FILE *file; size_t bytes_read = 0; - GRPC_IOMGR_START_BLOCKING_REGION; + GRPC_SCHEDULING_START_BLOCKING_REGION; file = fopen(filename, "rb"); if (file == NULL) { gpr_asprintf(&error_msg, "Could not open file %s (error = %s).", filename, @@ -86,6 +86,6 @@ end: if (success != NULL) *success = 0; } if (file != NULL) fclose(file); - GRPC_IOMGR_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION; return result; } diff --git a/src/core/support/time_posix.c b/src/core/support/time_posix.c index 889b63a88a..eedfd0a060 100644 --- a/src/core/support/time_posix.c +++ b/src/core/support/time_posix.c @@ -41,7 +41,7 @@ #include <unistd.h> #include <grpc/support/log.h> #include <grpc/support/time.h> -#include "src/core/iomgr/block_annotate.h" +#include "src/core/support/block_annotate.h" static struct timespec timespec_from_gpr(gpr_timespec gts) { struct timespec rv; @@ -139,9 +139,9 @@ void gpr_sleep_until(gpr_timespec until) { delta = gpr_time_sub(until, now); delta_ts = timespec_from_gpr(delta); - GRPC_IOMGR_START_BLOCKING_REGION; + GRPC_SCHEDULING_START_BLOCKING_REGION; ns_result = nanosleep(&delta_ts, NULL); - GRPC_IOMGR_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION; if (ns_result == 0) { break; } diff --git a/src/core/support/time_win32.c b/src/core/support/time_win32.c index 710c7969ba..bc0586d069 100644 --- a/src/core/support/time_win32.c +++ b/src/core/support/time_win32.c @@ -41,7 +41,7 @@ #include <src/core/support/time_precise.h> #include <sys/timeb.h> -#include "src/core/iomgr/block_annotate.h" +#include "src/core/support/block_annotate.h" static LARGE_INTEGER g_start_time; static double g_time_scale; @@ -94,9 +94,9 @@ void gpr_sleep_until(gpr_timespec until) { delta = gpr_time_sub(until, now); sleep_millis = (DWORD)delta.tv_sec * GPR_MS_PER_SEC + delta.tv_nsec / GPR_NS_PER_MS; - GRPC_IOMGR_START_BLOCKING_REGION; + GRPC_SCHEDULING_START_BLOCKING_REGION; Sleep(sleep_millis); - GRPC_IOMGR_END_BLOCKING_REGION; + GRPC_SCHEDULING_END_BLOCKING_REGION; } } |