Skip to content

Commit

Permalink
Internalize gpr_thd except for id and currentid
Browse files Browse the repository at this point in the history
  • Loading branch information
vjpai committed Feb 12, 2018
1 parent b09c58c commit c745690
Show file tree
Hide file tree
Showing 105 changed files with 188 additions and 214 deletions.
4 changes: 2 additions & 2 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ GPR_PUBLIC_HDRS = [
"include/grpc/support/sync_generic.h",
"include/grpc/support/sync_posix.h",
"include/grpc/support/sync_windows.h",
"include/grpc/support/thd.h",
"include/grpc/support/thd_id.h",
"include/grpc/support/time.h",
]

Expand Down Expand Up @@ -494,7 +494,7 @@ grpc_cc_library(
"src/core/lib/gpr/spinlock.h",
"src/core/lib/gpr/string.h",
"src/core/lib/gpr/string_windows.h",
"src/core/lib/gpr/thd_internal.h",
"src/core/lib/gpr/thd.h",
"src/core/lib/gpr/time_precise.h",
"src/core/lib/gpr/tls.h",
"src/core/lib/gpr/tls_gcc.h",
Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ foreach(_hdr
include/grpc/support/sync_generic.h
include/grpc/support/sync_posix.h
include/grpc/support/sync_windows.h
include/grpc/support/thd.h
include/grpc/support/thd_id.h
include/grpc/support/time.h
include/grpc/impl/codegen/atm.h
include/grpc/impl/codegen/atm_gcc_atomic.h
Expand Down Expand Up @@ -1679,7 +1679,7 @@ foreach(_hdr
include/grpc/support/sync_generic.h
include/grpc/support/sync_posix.h
include/grpc/support/sync_windows.h
include/grpc/support/thd.h
include/grpc/support/thd_id.h
include/grpc/support/time.h
include/grpc/impl/codegen/atm.h
include/grpc/impl/codegen/atm_gcc_atomic.h
Expand Down Expand Up @@ -1966,7 +1966,7 @@ foreach(_hdr
include/grpc/support/sync_generic.h
include/grpc/support/sync_posix.h
include/grpc/support/sync_windows.h
include/grpc/support/thd.h
include/grpc/support/thd_id.h
include/grpc/support/time.h
include/grpc/impl/codegen/atm.h
include/grpc/impl/codegen/atm_gcc_atomic.h
Expand Down Expand Up @@ -2525,7 +2525,7 @@ foreach(_hdr
include/grpc/support/sync_generic.h
include/grpc/support/sync_posix.h
include/grpc/support/sync_windows.h
include/grpc/support/thd.h
include/grpc/support/thd_id.h
include/grpc/support/time.h
include/grpc/impl/codegen/atm.h
include/grpc/impl/codegen/atm_gcc_atomic.h
Expand Down Expand Up @@ -2989,7 +2989,7 @@ foreach(_hdr
include/grpc/support/sync_generic.h
include/grpc/support/sync_posix.h
include/grpc/support/sync_windows.h
include/grpc/support/thd.h
include/grpc/support/thd_id.h
include/grpc/support/time.h
include/grpc/impl/codegen/atm.h
include/grpc/impl/codegen/atm_gcc_atomic.h
Expand Down Expand Up @@ -3710,7 +3710,7 @@ foreach(_hdr
include/grpc/support/sync_generic.h
include/grpc/support/sync_posix.h
include/grpc/support/sync_windows.h
include/grpc/support/thd.h
include/grpc/support/thd_id.h
include/grpc/support/time.h
include/grpc/impl/codegen/atm.h
include/grpc/impl/codegen/atm_gcc_atomic.h
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2935,7 +2935,7 @@ PUBLIC_HEADERS_C += \
include/grpc/support/sync_generic.h \
include/grpc/support/sync_posix.h \
include/grpc/support/sync_windows.h \
include/grpc/support/thd.h \
include/grpc/support/thd_id.h \
include/grpc/support/time.h \
include/grpc/impl/codegen/atm.h \
include/grpc/impl/codegen/atm_gcc_atomic.h \
Expand Down Expand Up @@ -3884,7 +3884,7 @@ PUBLIC_HEADERS_C += \
include/grpc/support/sync_generic.h \
include/grpc/support/sync_posix.h \
include/grpc/support/sync_windows.h \
include/grpc/support/thd.h \
include/grpc/support/thd_id.h \
include/grpc/support/time.h \
include/grpc/impl/codegen/atm.h \
include/grpc/impl/codegen/atm_gcc_atomic.h \
Expand Down Expand Up @@ -4164,7 +4164,7 @@ PUBLIC_HEADERS_C += \
include/grpc/support/sync_generic.h \
include/grpc/support/sync_posix.h \
include/grpc/support/sync_windows.h \
include/grpc/support/thd.h \
include/grpc/support/thd_id.h \
include/grpc/support/time.h \
include/grpc/impl/codegen/atm.h \
include/grpc/impl/codegen/atm_gcc_atomic.h \
Expand Down Expand Up @@ -4687,7 +4687,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/support/sync_generic.h \
include/grpc/support/sync_posix.h \
include/grpc/support/sync_windows.h \
include/grpc/support/thd.h \
include/grpc/support/thd_id.h \
include/grpc/support/time.h \
include/grpc/impl/codegen/atm.h \
include/grpc/impl/codegen/atm_gcc_atomic.h \
Expand Down Expand Up @@ -5164,7 +5164,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/support/sync_generic.h \
include/grpc/support/sync_posix.h \
include/grpc/support/sync_windows.h \
include/grpc/support/thd.h \
include/grpc/support/thd_id.h \
include/grpc/support/time.h \
include/grpc/impl/codegen/atm.h \
include/grpc/impl/codegen/atm_gcc_atomic.h \
Expand Down Expand Up @@ -5874,7 +5874,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc/support/sync_generic.h \
include/grpc/support/sync_posix.h \
include/grpc/support/sync_windows.h \
include/grpc/support/thd.h \
include/grpc/support/thd_id.h \
include/grpc/support/time.h \
include/grpc/impl/codegen/atm.h \
include/grpc/impl/codegen/atm_gcc_atomic.h \
Expand Down
4 changes: 2 additions & 2 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ filegroups:
- include/grpc/support/sync_generic.h
- include/grpc/support/sync_posix.h
- include/grpc/support/sync_windows.h
- include/grpc/support/thd.h
- include/grpc/support/thd_id.h
- include/grpc/support/time.h
headers:
- src/core/lib/gpr/arena.h
Expand All @@ -104,7 +104,7 @@ filegroups:
- src/core/lib/gpr/spinlock.h
- src/core/lib/gpr/string.h
- src/core/lib/gpr/string_windows.h
- src/core/lib/gpr/thd_internal.h
- src/core/lib/gpr/thd.h
- src/core/lib/gpr/time_precise.h
- src/core/lib/gpr/tls.h
- src/core/lib/gpr/tls_gcc.h
Expand Down
6 changes: 3 additions & 3 deletions gRPC-C++.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ Pod::Spec.new do |s|
'src/core/lib/gpr/spinlock.h',
'src/core/lib/gpr/string.h',
'src/core/lib/gpr/string_windows.h',
'src/core/lib/gpr/thd_internal.h',
'src/core/lib/gpr/thd.h',
'src/core/lib/gpr/time_precise.h',
'src/core/lib/gpr/tls.h',
'src/core/lib/gpr/tls_gcc.h',
Expand Down Expand Up @@ -464,7 +464,7 @@ Pod::Spec.new do |s|
'src/core/lib/gpr/spinlock.h',
'src/core/lib/gpr/string.h',
'src/core/lib/gpr/string_windows.h',
'src/core/lib/gpr/thd_internal.h',
'src/core/lib/gpr/thd.h',
'src/core/lib/gpr/time_precise.h',
'src/core/lib/gpr/tls.h',
'src/core/lib/gpr/tls_gcc.h',
Expand Down Expand Up @@ -654,7 +654,7 @@ Pod::Spec.new do |s|
'src/core/lib/gpr/spinlock.h',
'src/core/lib/gpr/string.h',
'src/core/lib/gpr/string_windows.h',
'src/core/lib/gpr/thd_internal.h',
'src/core/lib/gpr/thd.h',
'src/core/lib/gpr/time_precise.h',
'src/core/lib/gpr/tls.h',
'src/core/lib/gpr/tls_gcc.h',
Expand Down
6 changes: 3 additions & 3 deletions gRPC-Core.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ Pod::Spec.new do |s|
'include/grpc/support/sync_generic.h',
'include/grpc/support/sync_posix.h',
'include/grpc/support/sync_windows.h',
'include/grpc/support/thd.h',
'include/grpc/support/thd_id.h',
'include/grpc/support/time.h',
'include/grpc/impl/codegen/atm.h',
'include/grpc/impl/codegen/atm_gcc_atomic.h',
Expand Down Expand Up @@ -192,7 +192,7 @@ Pod::Spec.new do |s|
'src/core/lib/gpr/spinlock.h',
'src/core/lib/gpr/string.h',
'src/core/lib/gpr/string_windows.h',
'src/core/lib/gpr/thd_internal.h',
'src/core/lib/gpr/thd.h',
'src/core/lib/gpr/time_precise.h',
'src/core/lib/gpr/tls.h',
'src/core/lib/gpr/tls_gcc.h',
Expand Down Expand Up @@ -721,7 +721,7 @@ Pod::Spec.new do |s|
'src/core/lib/gpr/spinlock.h',
'src/core/lib/gpr/string.h',
'src/core/lib/gpr/string_windows.h',
'src/core/lib/gpr/thd_internal.h',
'src/core/lib/gpr/thd.h',
'src/core/lib/gpr/time_precise.h',
'src/core/lib/gpr/tls.h',
'src/core/lib/gpr/tls_gcc.h',
Expand Down
7 changes: 0 additions & 7 deletions grpc.def
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,7 @@ EXPORTS
gpr_stats_init
gpr_stats_inc
gpr_stats_read
gpr_thd_new
gpr_thd_options_default
gpr_thd_options_set_detached
gpr_thd_options_set_joinable
gpr_thd_options_is_detached
gpr_thd_options_is_joinable
gpr_thd_currentid
gpr_thd_join
gpr_time_0
gpr_inf_future
gpr_inf_past
Expand Down
4 changes: 2 additions & 2 deletions grpc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Gem::Specification.new do |s|
s.files += %w( include/grpc/support/sync_generic.h )
s.files += %w( include/grpc/support/sync_posix.h )
s.files += %w( include/grpc/support/sync_windows.h )
s.files += %w( include/grpc/support/thd.h )
s.files += %w( include/grpc/support/thd_id.h )
s.files += %w( include/grpc/support/time.h )
s.files += %w( include/grpc/impl/codegen/atm.h )
s.files += %w( include/grpc/impl/codegen/atm_gcc_atomic.h )
Expand All @@ -83,7 +83,7 @@ Gem::Specification.new do |s|
s.files += %w( src/core/lib/gpr/spinlock.h )
s.files += %w( src/core/lib/gpr/string.h )
s.files += %w( src/core/lib/gpr/string_windows.h )
s.files += %w( src/core/lib/gpr/thd_internal.h )
s.files += %w( src/core/lib/gpr/thd.h )
s.files += %w( src/core/lib/gpr/time_precise.h )
s.files += %w( src/core/lib/gpr/tls.h )
s.files += %w( src/core/lib/gpr/tls_gcc.h )
Expand Down
2 changes: 1 addition & 1 deletion include/grpc/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ framework module grpc {
header "support/string_util.h"
header "support/sync.h"
header "support/sync_generic.h"
header "support/thd.h"
header "support/thd_id.h"
header "support/time.h"
header "impl/codegen/atm.h"
header "impl/codegen/fork.h"
Expand Down
30 changes: 21 additions & 9 deletions src/core/lib/gpr/thd_internal.h → include/grpc/support/thd_id.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright 2015 gRPC authors.
* Copyright 2018 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,15 +16,27 @@
*
*/

#ifndef GRPC_CORE_LIB_GPR_THD_INTERNAL_H
#define GRPC_CORE_LIB_GPR_THD_INTERNAL_H
#ifndef GRPC_SUPPORT_THD_ID_H
#define GRPC_SUPPORT_THD_ID_H
/** Thread interface for GPR.
#include <grpc/support/time.h>
Types
gpr_thd_id a unique opaque identifier for a thread.
*/

#include <grpc/support/port_platform.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef uintptr_t gpr_thd_id;

/* Internal interfaces between modules within the gpr support library. */
void gpr_thd_init();
/** Returns the identifier of the current thread. */
GPRAPI gpr_thd_id gpr_thd_currentid(void);

/* Wait for all outstanding threads to finish, up to deadline */
int gpr_await_threads(gpr_timespec deadline);
#ifdef __cplusplus
}
#endif

#endif /* GRPC_CORE_LIB_GPR_THD_INTERNAL_H */
#endif /* GRPC_SUPPORT_THD_ID_H */
4 changes: 2 additions & 2 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<file baseinstalldir="/" name="include/grpc/support/sync_generic.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/sync_posix.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/sync_windows.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/thd.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/thd_id.h" role="src" />
<file baseinstalldir="/" name="include/grpc/support/time.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/atm.h" role="src" />
<file baseinstalldir="/" name="include/grpc/impl/codegen/atm_gcc_atomic.h" role="src" />
Expand All @@ -90,7 +90,7 @@
<file baseinstalldir="/" name="src/core/lib/gpr/spinlock.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/string.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/string_windows.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/thd_internal.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/thd.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/time_precise.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/tls.h" role="src" />
<file baseinstalldir="/" name="src/core/lib/gpr/tls_gcc.h" role="src" />
Expand Down
6 changes: 3 additions & 3 deletions src/core/lib/gpr/thd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
*
*/

/* Posix implementation for gpr threads. */
/* Platform-independent features for gpr threads. */

#include <string.h>
#include "src/core/lib/gpr/thd.h"

#include <grpc/support/thd.h>
#include <string.h>

enum { GPR_THD_JOINABLE = 1 };

Expand Down
48 changes: 20 additions & 28 deletions include/grpc/support/thd.h → src/core/lib/gpr/thd.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,17 @@
*
*/

#ifndef GRPC_SUPPORT_THD_H
#define GRPC_SUPPORT_THD_H
/** Thread interface for GPR.
#ifndef GRPC_CORE_LIB_GPR_THD_H
#define GRPC_CORE_LIB_GPR_THD_H
/** Internal thread interface for GPR.
Types
gpr_thd_id a thread identifier.
(Currently no calls take a thread identifier.
It exists for future extensibility.)
gpr_thd_options options used when creating a thread
*/

#include <grpc/support/port_platform.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef uintptr_t gpr_thd_id;
#include <grpc/support/thd_id.h>
#include <grpc/support/time.h>

/** Thread creation options. */
typedef struct {
Expand All @@ -46,34 +39,33 @@ typedef struct {
that support thread naming.
If options==NULL, default options are used.
The thread is immediately runnable, and exits when (*thd_body)() returns. */
GPRAPI int gpr_thd_new(gpr_thd_id* t, const char* thd_name,
void (*thd_body)(void* arg), void* arg,
const gpr_thd_options* options);
int gpr_thd_new(gpr_thd_id* t, const char* thd_name,
void (*thd_body)(void* arg), void* arg,
const gpr_thd_options* options);

/** Return a gpr_thd_options struct with all fields set to defaults. */
GPRAPI gpr_thd_options gpr_thd_options_default(void);
gpr_thd_options gpr_thd_options_default(void);

/** Set the thread to become detached on startup - this is the default. */
GPRAPI void gpr_thd_options_set_detached(gpr_thd_options* options);
void gpr_thd_options_set_detached(gpr_thd_options* options);

/** Set the thread to become joinable - mutually exclusive with detached. */
GPRAPI void gpr_thd_options_set_joinable(gpr_thd_options* options);
void gpr_thd_options_set_joinable(gpr_thd_options* options);

/** Returns non-zero if the option detached is set. */
GPRAPI int gpr_thd_options_is_detached(const gpr_thd_options* options);
int gpr_thd_options_is_detached(const gpr_thd_options* options);

/** Returns non-zero if the option joinable is set. */
GPRAPI int gpr_thd_options_is_joinable(const gpr_thd_options* options);

/** Returns the identifier of the current thread. */
GPRAPI gpr_thd_id gpr_thd_currentid(void);
int gpr_thd_options_is_joinable(const gpr_thd_options* options);

/** Blocks until the specified thread properly terminates.
Calling this on a detached thread has unpredictable results. */
GPRAPI void gpr_thd_join(gpr_thd_id t);
void gpr_thd_join(gpr_thd_id t);

/* Internal interfaces between modules within the gpr support library. */
void gpr_thd_init();

#ifdef __cplusplus
}
#endif
/* Wait for all outstanding threads to finish, up to deadline */
int gpr_await_threads(gpr_timespec deadline);

#endif /* GRPC_SUPPORT_THD_H */
#endif /* GRPC_CORE_LIB_GPR_THD_H */
Loading

0 comments on commit c745690

Please sign in to comment.