diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-12-19 07:14:39 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-12-19 07:17:57 -0800 |
| commit | 5e18eb4f18af570abf84a615db5235e2e9415c75 (patch) | |
| tree | ec1c8a7a58fed101f1f61651a5f319c64cfec329 /src/platform/posix/posix_pollq_kqueue.h | |
| parent | 0d39d4be2d4b53e8ede04364f082b3ba295979f2 (diff) | |
| download | nng-5e18eb4f18af570abf84a615db5235e2e9415c75.tar.gz nng-5e18eb4f18af570abf84a615db5235e2e9415c75.tar.bz2 nng-5e18eb4f18af570abf84a615db5235e2e9415c75.zip | |
posix pollers: expose pfd structures (for sizes) and fix poller selection
The poller selection in the previous poller changes for select were
not quite functional. Also, while testing poll() based poller, there
were problems where it simply did not work correctly, so this addresses
those, and it seems to work now.
The pfd structures are exposed as we intend to allow inlining them
to eliminate the separate allocation and potential for failure during
initialization. We also want to have plans afoot to eliminate a
lot of the extra locking done done on each I/O iteration, and this
is setting the foundation for that.
Diffstat (limited to 'src/platform/posix/posix_pollq_kqueue.h')
| -rw-r--r-- | src/platform/posix/posix_pollq_kqueue.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/platform/posix/posix_pollq_kqueue.h b/src/platform/posix/posix_pollq_kqueue.h new file mode 100644 index 00000000..74f8d9f8 --- /dev/null +++ b/src/platform/posix/posix_pollq_kqueue.h @@ -0,0 +1,34 @@ +// +// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2018 Capitar IT Group BV <info@capitar.com> +// +// This software is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +#ifndef PLATFORM_POSIX_POLLQ_KQUEUE_H +#define PLATFORM_POSIX_POLLQ_KQUEUE_H + +// nni_posix_pfd is the handle used by the poller. It's internals are private +// to the poller. +struct nni_posix_pfd { + nni_list_node node; // linkage into the reap list + struct nni_posix_pollq *pq; // associated pollq + int fd; // file descriptor to poll + void *arg; // user data + nni_posix_pfd_cb cb; // user callback on event + bool closed; + unsigned events; + nni_cv cv; // signaled when poller has unregistered + nni_mtx mtx; +}; + +#define NNI_POLL_IN (0x0001) +#define NNI_POLL_OUT (0x0010) +#define NNI_POLL_HUP (0x0004) +#define NNI_POLL_ERR (0x0008) +#define NNI_POLL_INVAL (0x0020) + +#endif // PLATFORM_POSIX_POLLQ_KQUEUE_H |
