-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapplication.h
42 lines (33 loc) · 891 Bytes
/
application.h
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
#pragma once
#include <atomic>
#include <functional>
#include "buffer_in.h"
#include "packet.h"
#include "pstream.h"
#include "session.h"
#include "time.h"
#include "types.h"
typedef struct {
std::function<void()> init;
std::function<bool(pstream *const ps, session *const s)> new_session;
std::function<bool(pstream *const ps, session *const s, buffer_in data)> new_data;
std::function<bool(pstream *const ps, session *const s)> session_closed_1; // please terminate
std::function<bool(pstream *const ps, session *const s)> session_closed_2; // should be terminated, clean up
std::function<void()> deinit;
private_data *pd;
} port_handler_t;
class application
{
protected:
interruptable_sleep stop_flag;
private_data *const pd { nullptr };
public:
application() {
}
virtual ~application() {
ask_to_stop();
}
void ask_to_stop() {
stop_flag.signal_stop();
}
};