开发者

Using iocp in a job pool

When using iocp in a job/task pool to provide fast worker wake ups what is the best way to minimise the overhead of signalling the port - ie not having to do it every queue operation?

void Worker() { while(1) { for(int spin = 0; spin < 5000; ++spin) while(queue.Count > 0) queue.PopFront()();

    WaitOnCompletionPort();
}

}

...

queue.PushBack(someWork); // decide when to signal completion port but avoid doing it every queue o开发者_JAVA百科peration ?

For example in the above rough code sketch there is a problem between work being queued and the wait being entered if you try and avoid signalling the port every queue operation.


Why don't you use the IOCP as your queue and post your work items directly to it? That way you get a thread safe queue for free and can completely remove the other queue you have?

This question would then go away ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜