载入中...
搜索中...
未找到
NetWorker.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "NetTypes.h"
6
7#include <atomic>
8#include <condition_variable>
9#include <functional>
10#include <mutex>
11#include <thread>
12#include <vector>
13
14namespace eve::network {
15
16class Network;
17
23public:
25 explicit NetWorker(Network* owner);
27 ~NetWorker();
28
30 void start();
32 void stop();
33
35 void post(NetCompletion c);
37 void drain(std::vector<NetCompletion>& out);
38
40 void submit(std::function<void()> job);
41
42private:
43 void threadMain();
44
45 Network* owner_ = nullptr;
46 std::mutex mu_;
47 std::condition_variable cv_;
48 std::vector<NetCompletion> completions_;
49 std::vector<std::function<void()>> jobs_;
50 std::thread thread_;
51 std::atomic<bool> running_{false};
52};
53
54} // namespace eve::network
Duration start
#define EVENGINE_API_PLATFORM
Definition Export.h:107
std::int32_t c
Background thread that runs blocking socket I/O and HTTP jobs. Completions are queued and drained by ...
Definition NetWorker.h:22
Network module: TCP/UDP/HTTP factories, background worker, and completion event plumbing....
Definition Network.h:35
One asynchronous network result/event. handle points at the originating TcpSocket/UdpSocket/HttpReque...
Definition NetTypes.h:33