From 382b4cff3abd5ccb282ba420ef1f7c7d171ec91a Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 4 Jan 2020 10:24:05 -0800 Subject: 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. --- src/core/pollable.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/core/pollable.h') 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 +// Copyright 2020 Staysail Systems, Inc. // // 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 -- cgit v1.2.3-70-g09d2