source: benchmark/io/http/worker.hfa

Last change on this file was 88ac843e, checked in by Thierry Delisle <tdelisle@…>, 3 months ago

Moved lockfree containers to containers/lockfree.hfa.
Added poison_list, which is a lock-free bag with push and poison as only operations.

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