ADT
ast-experimental
Last change
on this file since affb51b was 32d1383, checked in by Thierry Delisle <tdelisle@…>, 3 years ago |
Committing http server when I know it works
|
-
Property mode
set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | #pragma once
|
---|
2 |
|
---|
3 | #include <iofwd.hfa>
|
---|
4 | #include <queueLockFree.hfa>
|
---|
5 | #include <thread.hfa>
|
---|
6 |
|
---|
7 | extern "C" {
|
---|
8 | #include <sys/socket.h>
|
---|
9 | }
|
---|
10 |
|
---|
11 | #include "printer.hfa"
|
---|
12 |
|
---|
13 | //=============================================================================================
|
---|
14 | // Worker Thread
|
---|
15 | //=============================================================================================
|
---|
16 |
|
---|
17 | struct connection {
|
---|
18 | int pipe[2];
|
---|
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;
|
---|
31 | int sockfd;
|
---|
32 | struct sockaddr * addr;
|
---|
33 | socklen_t * addrlen;
|
---|
34 | int flags;
|
---|
35 | volatile bool done;
|
---|
36 | acceptor_stats_t stats;
|
---|
37 | };
|
---|
38 | void ?{}( AcceptWorker & this);
|
---|
39 | void main( AcceptWorker & );
|
---|
40 |
|
---|
41 |
|
---|
42 | struct 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 |
|
---|
54 | static inline PendingRead * volatile & ?`next ( PendingRead * node ) {
|
---|
55 | return node->next;
|
---|
56 | }
|
---|
57 |
|
---|
58 | thread ChannelWorker {
|
---|
59 | connection conn;
|
---|
60 | volatile bool done;
|
---|
61 | mpsc_queue(PendingRead) * queue;
|
---|
62 | };
|
---|
63 | void ?{}( ChannelWorker & );
|
---|
64 | void main( ChannelWorker & );
|
---|
65 |
|
---|
66 | thread 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 | };
|
---|
75 | void ?{}( Acceptor &, int cli );
|
---|
76 | void main( Acceptor & );
|
---|
Note:
See
TracBrowser
for help on using the repository browser.