Windows Thread Pool

Windows specific questions.
deltarho[1859]
Posts: 530
Joined: Jan 02, 2017 0:34
Location: UK

Re: Windows Thread Pool

Postby deltarho[1859] » May 31, 2017 16:40

The funny thing is the main feature of thread pooling is something which I have no use for - the pooling itself. At the outset I know how many work objects I will need. There is no question of a 'connection' opening up 'out of the blue' requiring another work object. The main attraction of thread pooling for me is the fact that the baby is not thrown out with the bath water as is the case with thread creation/destruction.

So, my world of thread pooling is much simpler than yours, Rick.

One problem I did have was with:

Code: Select all

Work = CreateThreadpoolWork(cast(PTP_WORK_CALLBACK,@myThread),cast(PVOID,Whatever), Null)

Work is carved in stone or, I should say, the TP_WORK structure is carved in stone. If 'Whatever' changes then we cannot use he same TP_WORK. So, instead of passing 'Whatever' I am passing the address of 'Whatever'. If 'Whatever' changes its address will not so we can use the same TP_WORK. Of course, BYREF would do the job for us but we cannot use that so I am using a '@'/'*' combination. Bit of a dog's dinner but even a dog's dinner is OK when we are hungry.<smile>
rpkelly
Posts: 38
Joined: Sep 03, 2016 22:36

Re: Windows Thread Pool

Postby rpkelly » May 31, 2017 18:00

This is why in my class, I don't reuse the TP_WORK object. I can pass whatever is needed at the time.

Code: Select all

' =====================================================================================
' Create Thread Work
' =====================================================================================
 
Private Sub cCTServerThreadPool.CreateThreadWork (ByVal pfnwk as PTP_WORK_CALLBACK, _
                                                  ByVal pv as PVOID)
 
Dim Work          as PTP_WORK

     Work = CreateThreadpoolWork(pfnwk,pv,This.cbe)
     SubmitThreadpoolWork(Work)
     CloseThreadpoolWork(Work)                                                   
 
End Sub
deltarho[1859]
Posts: 530
Joined: Jan 02, 2017 0:34
Location: UK

Re: Windows Thread Pool

Postby deltarho[1859] » May 31, 2017 18:53

Again, a different environment. My TP_WORK structure is being used over and over again on buffers whose contents are changing.

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 1 guest