We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
你好! RunInThread中一次把同步队列中的任务都右值引用了,这样也是单个线程里依次在跑所有的任务啊。而不是分别在各个线程中跑一个任务? 请问我的理解有错误么?谢谢
void RunInThread() { while (m_running) { //取任务分别执行 std::list<Task> list; m_queue.Take(list); for (auto& task : list) { if (!m_running) return; task(); } } }
The text was updated successfully, but these errors were encountered:
这个看使用场景,如果生产者和消费者达到一个平衡的情况下,比如每次入队几个任务,每次出队几个任务的时候,一个线程一次取走全部的几个任务是可以的,还能有一点性能优化,不必每次取任务都去加锁一次,这里是取一批任务加锁一次。一般情况下不这样用,还是一次一个任务的好。
Sorry, something went wrong.
@qicosmos 大佬解释下为什么一次一个任务好?
No branches or pull requests
你好! RunInThread中一次把同步队列中的任务都右值引用了,这样也是单个线程里依次在跑所有的任务啊。而不是分别在各个线程中跑一个任务?
请问我的理解有错误么?谢谢
The text was updated successfully, but these errors were encountered: