worker.c
1001 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <stdarg.h>
#include "class.h"
#include "http/worker.h"
#include "http/request/parser.h"
#include "http/response/writer.h"
#include "interface/class.h"
#include "interface/stream_reader.h"
#include "interface/stream_writer.h"
static
void
ctor(void * _this, va_list * params)
{
HttpWorker this = _this;
this->parser = new(HttpRequestParser);
this->writer = new(HttpResponseWriter);
}
static
void
dtor(void * _this)
{
HttpWorker this = _this;
delete(&this->parser);
delete(&this->writer);
}
static
void
_clone(void * _this, void * _base)
{
/**
* TODO: this actually simply creates a new worker
* and ignores the base. Think about this.
*/
va_list foo;
ctor(_this, &foo);
}
INIT_IFACE(Class, ctor, dtor, _clone);
INIT_IFACE(StreamReader, (fptr_streamReaderRead)httpWorkerProcess);
INIT_IFACE(StreamWriter, (fptr_streamWriterWrite)httpWorkerWrite);
CREATE_CLASS(
HttpWorker,
NULL,
IFACE(Class),
IFACE(StreamReader),
IFACE(StreamWriter));
// vim: set ts=4 sw=4: