载入中...
搜索中...
未找到
Channel.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include <condition_variable>
6#include <memory>
7#include <mutex>
8#include <queue>
9#include <string>
10
11namespace eve {
12namespace thread {
13
20public:
22 Channel();
24 explicit Channel(std::string name);
27
29 std::string getName() const;
30
32 void push(std::string value);
34 std::string pop();
36 std::string demand();
38 std::string supply(int timeoutMs);
39
41 bool hasData() const;
43 int getCount() const;
45 void clear();
46
47private:
48 struct State {
50 explicit State(std::string channelName = {}) : name(std::move(channelName)) {}
51
52 std::string name;
53 mutable std::mutex mu;
54 std::condition_variable cv;
55 std::queue<std::string> queue;
56 };
57
58 std::shared_ptr<State> state_;
59
60 friend class ThreadPool;
61};
62
63} // namespace thread
64} // namespace eve
double value
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
std::string name
Thread-safe message queue (love2d-style Channel). Values are strings so the API stays overload-free f...
Definition Channel.h:19
Fixed-size worker pool. Owns worker std::threads; tasks run FIFO. Squirrel VM is not thread-safe — do...
Definition ThreadPool.h:26
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
std::mutex mu
Definition Graphics.cpp:181