#pragma once #include #include #include extern "C" { #include } #include "printer.hfa" //============================================================================================= // Worker Thread //============================================================================================= 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; acceptor_stats_t stats; }; 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; acceptor_stats_t stats; }; void ?{}( Acceptor &, int cli ); void main( Acceptor & );