aboutsummaryrefslogtreecommitdiff
path: root/src/core/pollable.h
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2020-01-04 10:24:05 -0800
committerGarrett D'Amore <garrett@damore.org>2020-01-04 10:56:40 -0800
commit382b4cff3abd5ccb282ba420ef1f7c7d171ec91a (patch)
tree6860e1cceb52a7dab2763001eb27edf95a0e7246 /src/core/pollable.h
parentbcc3814b58e9b198344bdaf6e7a916a354841275 (diff)
downloadnng-382b4cff3abd5ccb282ba420ef1f7c7d171ec91a.tar.gz
nng-382b4cff3abd5ccb282ba420ef1f7c7d171ec91a.tar.bz2
nng-382b4cff3abd5ccb282ba420ef1f7c7d171ec91a.zip
fixes #1105 pollable can be inlined, and use atomics
This also introduces an nni_atomic_cas64 to help with lock-free designs. Some mechanical renaming was done in some of the protocols for spelling.
Diffstat (limited to 'src/core/pollable.h')
-rw-r--r--src/core/pollable.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/core/pollable.h b/src/core/pollable.h
index 50ec9bf6..a71a9693 100644
--- a/src/core/pollable.h
+++ b/src/core/pollable.h
@@ -1,5 +1,5 @@
//
-// Copyright 2017 Garrett D'Amore <garrett@damore.org>
+// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -13,8 +13,6 @@
#include "core/defs.h"
#include "core/list.h"
-// For the sake of simplicity, we just maintain a single global timer thread.
-
typedef struct nni_pollable nni_pollable;
extern int nni_pollable_alloc(nni_pollable **);
@@ -23,4 +21,16 @@ extern void nni_pollable_raise(nni_pollable *);
extern void nni_pollable_clear(nni_pollable *);
extern int nni_pollable_getfd(nni_pollable *, int *);
+// nni_pollable implementation details are private. Only here for inlining.
+// We have joined to the write and read file descriptors into a a single
+// atomic 64 so we can update them together (and we can use cas to be sure
+// that such updates are always safe.)
+struct nni_pollable {
+ nni_atomic_u64 p_fds;
+ nni_atomic_bool p_raised;
+};
+
+extern void nni_pollable_init(nni_pollable *);
+extern void nni_pollable_fini(nni_pollable *);
+
#endif // CORE_POLLABLE_H