#pragma once #include #include #include extern "C" { #include } //============================================================================================= // Worker Thread //============================================================================================= extern const size_t zipf_sizes[]; enum { zipf_cnts = 36, }; struct sendfile_stats_t { volatile uint64_t calls; volatile uint64_t tries; volatile uint64_t header; volatile uint64_t splcin; volatile uint64_t splcot; struct { volatile uint64_t calls; volatile uint64_t bytes; } avgrd[zipf_cnts]; }; void ?{}( sendfile_stats_t & this ); struct connection { int pipe[2]; struct { sendfile_stats_t sendfile; } stats; }; static inline void ?{}( connection & this ) { this.pipe[0] = -1; this.pipe[1] = -1; } thread AcceptWorker { connection conn; int sockfd; struct sockaddr * addr; socklen_t * addrlen; int flags; volatile bool done; }; void ?{}( AcceptWorker & this); void main( AcceptWorker & ); struct PendingRead { PendingRead * volatile next; io_future_t f; struct { void * buf; size_t len; } in; struct { volatile int fd; } out; }; static inline PendingRead * volatile & ?`next ( PendingRead * node ) { return node->next; } thread ChannelWorker { connection conn; volatile bool done; mpsc_queue(PendingRead) * queue; }; void ?{}( ChannelWorker & ); void main( ChannelWorker & ); thread Acceptor { mpsc_queue(PendingRead) * queue; int sockfd; struct sockaddr * addr; socklen_t * addrlen; int flags; volatile bool done; }; void ?{}( Acceptor & ); void main( Acceptor & );