diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-06-27 20:06:42 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-06-27 20:06:42 -0700 |
| commit | e2d17be2a7081888aaafea150d587a7ef9517e17 (patch) | |
| tree | d438d8c0e401dd70d81a003846c53568f1730e3a /src/platform/posix/posix_aio.h | |
| parent | ac80ef7c3b1caa2f1fe3b093bef825363675bcb3 (diff) | |
| download | nng-e2d17be2a7081888aaafea150d587a7ef9517e17.tar.gz nng-e2d17be2a7081888aaafea150d587a7ef9517e17.tar.bz2 nng-e2d17be2a7081888aaafea150d587a7ef9517e17.zip | |
Convert to POSIX polled I/O for async; start of cancelable aio.
This eliminates the two threads per pipe that were being used to provide
basic I/O handling, replacing them with a single global thread for now,
that uses poll and nonblocking I/O. This should lead to great scalability.
The infrastructure is in place to easily expand to multiple polling worker
threads. Some thought needs to be given about how to scale this to engage
multiple CPUs. Horizontal scaling may also shorten the poll() lists easing
C10K problem.
We should look into better solutions than poll() for platforms that have
them (epoll on Linux, kqueue on BSD, and event ports on illumos).
Note that the file descriptors start out in blocking mode for now, but
then are placed into non-blocking mode. This is because the negotiation
phase is not yet callback driven, and so needs to be synchronous.
Diffstat (limited to 'src/platform/posix/posix_aio.h')
| -rw-r--r-- | src/platform/posix/posix_aio.h | 44 |
1 files changed, 7 insertions, 37 deletions
diff --git a/src/platform/posix/posix_aio.h b/src/platform/posix/posix_aio.h index 797f9e43..9ab322a0 100644 --- a/src/platform/posix/posix_aio.h +++ b/src/platform/posix/posix_aio.h @@ -18,43 +18,13 @@ #include "core/nng_impl.h" -typedef struct nni_posix_aioq nni_posix_aioq; -typedef struct nni_posix_aiof nni_posix_aiof; -typedef struct nni_posix_aio_pipe nni_posix_aio_pipe; -typedef struct nni_posix_aio_ep nni_posix_aio_ep; -// Head structure representing file operations for read/write. We process -// the list of aios serially, and each file has its own thread for now. -struct nni_posix_aioq { - nni_list aq_aios; - int aq_fd; - nni_mtx aq_lk; - nni_cv aq_cv; -#ifdef NNG_USE_POSIX_AIOTHR - nni_thr aq_thr; -#endif -}; - -struct nni_posix_aio_pipe { - int ap_fd; - nni_posix_aioq ap_readq; - nni_posix_aioq ap_writeq; -}; - -struct nni_posix_aio_ep { - int ap_fd; - nni_posix_aioq ap_q; -}; - -extern int nni_posix_aio_pipe_init(nni_posix_aio_pipe *, int); -extern void nni_posix_aio_pipe_fini(nni_posix_aio_pipe *); - -// extern int nni_posix_aio_ep_init(nni_posix_aio_ep *, int); -// extern void nni_posix_aio_ep_fini(nni_posix_aio_ep *); -extern int nni_posix_aio_read(nni_posix_aio_pipe *, nni_aio *); -extern int nni_posix_aio_write(nni_posix_aio_pipe *, nni_aio *); - -// extern int nni_posix_aio_connect(); -// extern int nni_posix_aio_accept(); +typedef struct nni_posix_pipedesc nni_posix_pipedesc; +extern int nni_posix_pipedesc_sysinit(void); +extern void nni_posix_pipedesc_sysfini(void); +extern int nni_posix_pipedesc_init(nni_posix_pipedesc **, int); +extern void nni_posix_pipedesc_fini(nni_posix_pipedesc *); +extern int nni_posix_pipedesc_read(nni_posix_pipedesc *, nni_aio *); +extern int nni_posix_pipedesc_write(nni_posix_pipedesc *, nni_aio *); #endif // PLATFORM_POSIX_AIO_H |
