diff options
author | David Klempner <klempner@google.com> | 2015-01-26 15:02:51 -0800 |
---|---|---|
committer | David Klempner <klempner@google.com> | 2015-01-26 15:02:51 -0800 |
commit | 78dc6cdaeb533cb03cd8a3b3bea6e6d7847083aa (patch) | |
tree | b081c89172b5dcb21847ab14c6fd19986a24c881 /src/core/iomgr/pollset_kick.h | |
parent | dbb4f942d05321e7c29f67ee1057aca7238d1f3a (diff) |
Refactor the pipe/eventfd abstraction
This introduces the wakeup fd interface, corresponding approximately to
the existing Google version, complete with a ported giant detailed usage
comment.
The implementation has two layers, "specialized" and "fallback". The
specialized layer is intended to be a suitable platform specific
implementation like eventfd, whereas "fallback" is probably pipe, with
runtime detection of whether the specialized version works on this
system (currently stubbed out).
Diffstat (limited to 'src/core/iomgr/pollset_kick.h')
-rw-r--r-- | src/core/iomgr/pollset_kick.h | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/core/iomgr/pollset_kick.h b/src/core/iomgr/pollset_kick.h index 4459a31b4f..5e90931261 100644 --- a/src/core/iomgr/pollset_kick.h +++ b/src/core/iomgr/pollset_kick.h @@ -34,27 +34,33 @@ #ifndef __GRPC_INTERNAL_IOMGR_POLLSET_KICK_H_ #define __GRPC_INTERNAL_IOMGR_POLLSET_KICK_H_ -#include <grpc/support/port_platform.h> +#include "src/core/iomgr/wakeup_fd.h" +#include <grpc/support/sync.h> /* This is an abstraction around the typical pipe mechanism for waking up a thread sitting in a poll() style call. */ -#ifdef GPR_POSIX_SOCKET -#include "src/core/iomgr/pollset_kick_posix.h" -#else -#error "No pollset kick support on platform" -#endif +typedef struct grpc_kick_fd_info { + grpc_wakeup_fd_info wakeup_fd; + struct grpc_kick_fd_info *next; +} grpc_kick_fd_info; + +typedef struct grpc_pollset_kick_state { + gpr_mu mu; + int kicked; + struct grpc_kick_fd_info *fd_info; +} grpc_pollset_kick_state; void grpc_pollset_kick_global_init(void); void grpc_pollset_kick_global_destroy(void); -/* Guarantees a pure posix implementation rather than a specialized one, if - * applicable. Intended for testing. */ -void grpc_pollset_kick_global_init_posix(void); - void grpc_pollset_kick_init(grpc_pollset_kick_state *kick_state); void grpc_pollset_kick_destroy(grpc_pollset_kick_state *kick_state); +/* Guarantees a pure posix implementation rather than a specialized one, if + * applicable. Intended for testing. */ +void grpc_pollset_kick_global_init_fallback_fd(void); + /* Must be called before entering poll(). If return value is -1, this consumed an existing kick. Otherwise the return value is an FD to add to the poll set. */ |