ADTast-experimentalpthread-emulationqualifiedEnum
Last change
on this file since 430ce61 was
137974ae,
checked in by Thierry Delisle <tdelisle@…>, 2 years ago
|
Moved stats printer to it's own file and now using push-stats rather than pull
|
-
Property mode set to
100644
|
File size:
1.3 KB
|
Rev | Line | |
---|
[0aec496] | 1 | #pragma once |
---|
| 2 | |
---|
[7f0ac12] | 3 | #include <iofwd.hfa> |
---|
| 4 | #include <queueLockFree.hfa> |
---|
[0aec496] | 5 | #include <thread.hfa> |
---|
| 6 | |
---|
| 7 | extern "C" { |
---|
| 8 | #include <sys/socket.h> |
---|
| 9 | } |
---|
| 10 | |
---|
[137974ae] | 11 | #include "printer.hfa" |
---|
| 12 | |
---|
[0aec496] | 13 | //============================================================================================= |
---|
| 14 | // Worker Thread |
---|
| 15 | //============================================================================================= |
---|
| 16 | |
---|
[7f0ac12] | 17 | struct connection { |
---|
[0aec496] | 18 | int pipe[2]; |
---|
[7f0ac12] | 19 | struct { |
---|
| 20 | sendfile_stats_t sendfile; |
---|
| 21 | } stats; |
---|
| 22 | }; |
---|
| 23 | |
---|
| 24 | static inline void ?{}( connection & this ) { |
---|
| 25 | this.pipe[0] = -1; |
---|
| 26 | this.pipe[1] = -1; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | thread AcceptWorker { |
---|
| 30 | connection conn; |
---|
[0aec496] | 31 | int sockfd; |
---|
| 32 | struct sockaddr * addr; |
---|
| 33 | socklen_t * addrlen; |
---|
| 34 | int flags; |
---|
[481ee28] | 35 | volatile bool done; |
---|
[7f0ac12] | 36 | }; |
---|
| 37 | void ?{}( AcceptWorker & this); |
---|
| 38 | void main( AcceptWorker & ); |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | struct PendingRead { |
---|
| 42 | PendingRead * volatile next; |
---|
| 43 | io_future_t f; |
---|
[ef3c383] | 44 | struct { |
---|
[7f0ac12] | 45 | void * buf; |
---|
| 46 | size_t len; |
---|
| 47 | } in; |
---|
| 48 | struct { |
---|
| 49 | volatile int fd; |
---|
| 50 | } out; |
---|
| 51 | }; |
---|
| 52 | |
---|
| 53 | static inline PendingRead * volatile & ?`next ( PendingRead * node ) { |
---|
| 54 | return node->next; |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | thread ChannelWorker { |
---|
| 58 | connection conn; |
---|
| 59 | volatile bool done; |
---|
| 60 | mpsc_queue(PendingRead) * queue; |
---|
| 61 | }; |
---|
| 62 | void ?{}( ChannelWorker & ); |
---|
| 63 | void main( ChannelWorker & ); |
---|
| 64 | |
---|
| 65 | thread Acceptor { |
---|
| 66 | mpsc_queue(PendingRead) * queue; |
---|
| 67 | int sockfd; |
---|
| 68 | struct sockaddr * addr; |
---|
| 69 | socklen_t * addrlen; |
---|
| 70 | int flags; |
---|
| 71 | volatile bool done; |
---|
[137974ae] | 72 | acceptor_stats_t stats; |
---|
[0aec496] | 73 | }; |
---|
[7f0ac12] | 74 | void ?{}( Acceptor & ); |
---|
| 75 | void main( Acceptor & ); |
---|
Note: See
TracBrowser
for help on using the repository browser.