1

Topic: CThreadPool

All greetings,


Decided to get acquainted more tightly here with multi-threaded request processing from clients on the server
smile
Before had no business with thread pool never.

Very actively I use ATL, on it my sight naturally fell on CThreadPool.


Having transversed a little on a forum clarified that is at it like a problem with shutdown, the pier queue of requests does not break and fulfilled up to the end. Itself did not check still, all only from sketchy posts on a forum.

I use studio VS9.0, this problem already can in atl later versions was is solved?

Can eat still any implemented pools on which it is necessary to turn the look? boost not to offer)

2

Re: CThreadPool

Why that was not , in general it is my post.


If who uses what  thread pool - rush the link, well and to steam of words about it.

3

Re: CThreadPool

I will a little describe the task.


It is necessary to process requests from users, requests , mid frequency of requests I think nearby 5 in a second, requests are in most cases processed quickly. In peak can be requests 20-30 in a second will.

Function which will pull thread pool, comprises a full stroke of handling of connection with the client - the synchronous reading of a command from a socket, a command location in queue of commands, queue processes other flow, waiting of formation of the answer for the command, sending of the answer to the client.


CthreadPool how I understood, it is made on the basis of IOCP? On how many it approaches my task? Can what nuances did not consider?

4

Re: CThreadPool

Where it is possible to look at an example on CThreadPool, and that of couples I can not find, even in msdn.

5

Re: CThreadPool

Hello, Hayabusa, you wrote:

H> If who uses what  thread pool  rush the link, well and to steam of words about it.


Something answers in a subject absolutely are not present. And too it would be interesting to me to esteem briefly about different .

Who can throws a reference on the description of different variants of implementations?


Offtopic. From myself I can tell briefly about snap ThreadPool' in . Since version 4.0 in it it is implemented
work stealing. In each flow there is a local job queue, flew down LIFO more truly. Thanks to it happens cache miss less often.

6

Re: CThreadPool

Hello, the Anonymous author, you wrote:

Having transversed a little on a forum clarified that is at it like a problem with shutdown, the pier queue of requests does not break and fulfilled up to the end. Itself did not check still, all only from sketchy posts on a forum.
I Use studio VS9.0, this problem already can in atl later versions was is solved?


Implementation in ATL uses IOCP.

All tasks are put in queue.

Call Shutdown adds in job queue "finish operation" in an amount equal to an amount of flows.

All tasks are fulfilled as FIFO.

I.e., all tasks which are at the moment of call Shutdown, will be fulfilled.


In implementation ATL nobody hinders to add tasks at the moment of call Shutdown, i.e. it is possible to have time to add new tasks after atl th jobs "finish operation".

These new tasks will not be fulfilled.

7

Re: CThreadPool

Hello, Hayabusa, you wrote:

H> I will a little describe the task.

H> Function which will pull thread pool, comprises a full stroke of handling of connection with the client  the synchronous reading of a command from a socket, a command location in queue of commands, queue processes other flow,


What another - too from a pool?

H> waiting of formation of the answer for a command,


The flow of a pool will wait also for nothing to do?

H> sending of the answer to the client.

H> CthreadPool how I understood, it is made on the basis of IOCP?


Yes

H> On how many it approaches my task? Can what nuances did not consider?


Simple pool. Quite resembles.

8

Re: CThreadPool

Hello, rus blood, you wrote:

RB> What another  too from a pool?


No, other flow.

H>> waiting of formation of the answer for a command,

RB> the flow of a pool will wait also for nothing to do?


Yes, so.

I understand that something is wrong in this circuit, but while so)

9

Re: CThreadPool

Hello, rus blood, you wrote:

RB> Implementation in ATL uses IOCP.
RB> All tasks are put in queue.
RB> Call Shutdown adds in job queue "finish operation" in an amount equal to an amount of flows.
RB> All tasks are fulfilled as FIFO.
RB> I.e., all tasks which are at the moment of call Shutdown, will be fulfilled.


I.e. such mechanism turned out because of usage IOCP?

I mean that it is impossible to interrupt job queue handling.

And not to bypass in any way at usage of this pool?

RB> In implementation ATL nobody hinders to add tasks at the moment of call Shutdown, i.e. it is possible to have time to add new tasks after atl th jobs "finish operation".
RB> These new tasks will not be fulfilled.


About tasks after shutdown - well  and so it is clear)