载入中...
搜索中...
未找到
Thread.h
浏览该文件的文档.
1#pragma once
2
3#include "common/Module.h"
4#include "thread/Channel.h"
5#include "thread/JobSystem.h"
6#include "thread/Task.h"
7#include "thread/ThreadPool.h"
8
9#include <map>
10#include <memory>
11#include <mutex>
12#include <string>
13
14namespace eve {
15namespace thread {
16
21class Thread : public Module {
22public:
24
26 ~Thread() override;
27
29 int getHardwareConcurrency() const;
30
33
35 ThreadPool *newThreadPool(int workerCount = 0);
36
43
48 Channel *getChannel(std::string name);
49
52
57 void postMain(std::string name, std::string data = "");
58
59private:
60 std::mutex mu_;
61 std::unique_ptr<ThreadPool> defaultPool_;
62 std::unique_ptr<JobSystem> defaultJobSystem_;
63 std::map<std::string, std::unique_ptr<Channel>> namedChannels_;
64};
65
66} // namespace thread
67} // namespace eve
const char * name
Definition RockMesh.cpp:21
Thread-safe message queue (love2d-style Channel). Values are strings so the API stays overload-free f...
Definition Channel.h:17
Abstract job scheduler: dependencies, parallel_for, task_group, arena.
Definition JobSystem.h:153
Fixed-size worker pool. Owns worker std::threads; tasks run FIFO. Squirrel VM is not thread-safe — do...
Definition ThreadPool.h:24
Thread module: default pool, named channels, pool factory. Script: eve.Thread() → getPool / newThread...
Definition Thread.h:21
Channel * newChannel()
Anonymous channel (not registered in the name map). Caller owns it.
Definition Thread.cpp:64
ThreadPool * getPool()
Shared default pool (created lazily with hardwareConcurrency workers).
Definition Thread.cpp:31
void postMain(std::string name, std::string data="")
Thread-safe post onto the Event module queue (any thread). Main loop: event.pump is unrelated; just e...
Definition Thread.cpp:66
JobSystem * getJobSystem()
Shared engine-wide JobSystem (created lazily with hardware concurrency workers). Use it for dependenc...
Definition Thread.cpp:44
Channel * getChannel(std::string name)
Named shared channel (love2d-style). Same name → same Channel instance for the lifetime of the module...
Definition Thread.cpp:51
ThreadPool * newThreadPool(int workerCount=0)
Create an independent pool. Caller owns it (delete when done).
Definition Thread.cpp:38
int getHardwareConcurrency() const
Hardware concurrency hint (at least 1).
Definition Thread.cpp:26
~Thread() override
Definition Thread.cpp:19
Definition Build.cpp:11