diff options
author | 2015-04-03 13:32:47 -0700 | |
---|---|---|
committer | 2015-04-03 23:02:47 +0200 | |
commit | 91647cc8154b06df9225eaa67b03b05fbb353043 (patch) | |
tree | 7a8e86cfd6f2c983aaa276f440061b299fe79151 /include | |
parent | 300ebc4c623b46f45506ac14b31e2660196dc596 (diff) |
Adding joinable threads, and gpr_thd_join.
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc/support/thd.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/include/grpc/support/thd.h b/include/grpc/support/thd.h index 64d5bed49a..8126992d6b 100644 --- a/include/grpc/support/thd.h +++ b/include/grpc/support/thd.h @@ -52,9 +52,8 @@ typedef gpr_uint64 gpr_thd_id; /* Thread creation options. */ typedef struct { - int flags; /* Flags below can be set here. Default value 0. */ + int flags; /* Opaque field. Get and set with accessors below. */ } gpr_thd_options; -/* No flags are currently defined. */ /* Create a new thread running (*thd_body)(arg) and place its thread identifier in *t, and return true. If there are insufficient resources, return false. @@ -66,9 +65,25 @@ int gpr_thd_new(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg, /* Return a gpr_thd_options struct with all fields set to defaults. */ gpr_thd_options gpr_thd_options_default(void); +/* Set the thread to become detached on startup - this is the default. */ +void gpr_thd_options_set_detached(gpr_thd_options *options); + +/* Set the thread to become joinable - mutually exclusive with detached. */ +void gpr_thd_options_set_joinable(gpr_thd_options *options); + +/* Returns non-zero if the option detached is set. */ +int gpr_thd_options_is_detached(const gpr_thd_options *options); + +/* Returns non-zero if the option joinable is set. */ +int gpr_thd_options_is_joinable(const gpr_thd_options *options); + /* Returns the identifier of the current thread. */ gpr_thd_id gpr_thd_currentid(void); +/* Blocks until the specified thread properly terminates. + Calling this on a detached thread has unpredictable results. */ +void gpr_thd_join(gpr_thd_id t); + #ifdef __cplusplus } #endif |