source: benchmark/io/http/worker.hfa @ 8c58e73

ADTast-experimentalpthread-emulationqualifiedEnum
Last change on this file since 8c58e73 was 7f0ac12, checked in by Thierry Delisle <tdelisle@…>, 2 years ago

First draft at acceptor thread webserver

  • Property mode set to 100644
File size: 1.6 KB
Line 
1#pragma once
2
3#include <iofwd.hfa>
4#include <queueLockFree.hfa>
5#include <thread.hfa>
6
7extern "C" {
8        #include <sys/socket.h>
9}
10
11//=============================================================================================
12// Worker Thread
13//=============================================================================================
14
15extern const size_t zipf_sizes[];
16enum { zipf_cnts = 36, };
17
18struct sendfile_stats_t {
19        volatile uint64_t calls;
20        volatile uint64_t tries;
21        volatile uint64_t header;
22        volatile uint64_t splcin;
23        volatile uint64_t splcot;
24        struct {
25                volatile uint64_t calls;
26                volatile uint64_t bytes;
27        } avgrd[zipf_cnts];
28};
29
30void ?{}( sendfile_stats_t & this );
31
32struct connection {
33        int pipe[2];
34        struct {
35                sendfile_stats_t sendfile;
36        } stats;
37};
38
39static inline void ?{}( connection & this ) {
40        this.pipe[0] = -1;
41        this.pipe[1] = -1;
42}
43
44thread AcceptWorker {
45        connection conn;
46        int sockfd;
47        struct sockaddr * addr;
48        socklen_t * addrlen;
49        int flags;
50        volatile bool done;
51};
52void ?{}( AcceptWorker & this);
53void main( AcceptWorker & );
54
55
56struct PendingRead {
57        PendingRead * volatile next;
58        io_future_t f;
59        struct {
60                void * buf;
61                size_t len;
62        } in;
63        struct {
64                volatile int fd;
65        } out;
66};
67
68static inline PendingRead * volatile & ?`next ( PendingRead * node ) {
69        return node->next;
70}
71
72thread ChannelWorker {
73        connection conn;
74        volatile bool done;
75        mpsc_queue(PendingRead) * queue;
76};
77void ?{}( ChannelWorker & );
78void main( ChannelWorker & );
79
80thread Acceptor {
81        mpsc_queue(PendingRead) * queue;
82        int sockfd;
83        struct sockaddr * addr;
84        socklen_t * addrlen;
85        int flags;
86        volatile bool done;
87};
88void ?{}( Acceptor & );
89void main( Acceptor & );
Note: See TracBrowser for help on using the repository browser.