zl程序教程

您现在的位置是:首页 >  后端

当前栏目

c++消息队列的实现详解编程语言

2023-06-13 09:11:49 时间
ThreadPool Type ::ThreadPool(int32_t threads, std::function void(Type record) handler) : _shutdown(false), _threads(threads), _handler(handler), _workers(), _tasks() { if (_threads MIN_THREADS) _threads = MIN_THREADS; for (int32_t i = 0; i _threads; ++i) _workers.emplace_back( [this] { while (!_shutdown) { Type record; _tasks.Pop(record, true); _handler(record); template class Type ThreadPool Type ::~ThreadPool() { for (std::thread worker: _workers) worker.join(); template class Type void ThreadPool Type ::Submit(Type record) { _tasks.Push(record); #endif //NET_FRAME_THREAD_POOL_H

18481.html

cjava