Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » what about WorkQueue : public CoWork
Re: changed CoWork and derived WorkQueue [message #24910 is a reply to message #24907] Wed, 03 February 2010 21:58 Go to previous messageGo to previous message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
hi mirek,

i think i got your point. the only thing to ensure about a work queue instance (or a given CoWork instance) is, the instance has to ensure that no other task is dequeued (to be executed in another parallel thread of static pool) before the previous task posted to the queue has been completed.

semantically speaking: the taks posted/enqueued into a CoWork instance have per se nothing to do with the pool itself, which presents the ability to execute arbitrary things anyway.

so probably the following would be right:

to make the struct Pool not private part of CoWork, but maybe protected. so a derived WorkQueue can reuse the static pool,
it can derive protected from CoWork to hide away the public interface (for not using virtuals), since most part of CoWork is proteced anyway, the WorkQueue then basicly needs to provide the same interface (Do() and operator &()), which then simply invoke a Finish() before handing over to CoWork::Do(). one could also use a CoWork directly, before enqueing any further task, simply ensure the one before is finished...so this is almost what you provided some post before..with the scoped CoWork approach..the only difference is that the CoWork is not created all over again and again, but used the same instance.

but one draw back is there: invoking Finish before enqueuing new task implies that the posting thread is halted until a previous task has terminated..this is not the case with current WorkQueue, which always dequeus, but to 1 thread only, so no other task can run in the queue. but if meanwhile another task has been queued, it is then executed right after, without having the posting task to wait for completion of previous one.

maybe the WorkQueue should be a class of it self, dequeuing differently then the CoWork does..

i'll try that.. but generally speaking, does all that make any sense to you anyway?

thanks for the patience
kostah
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: DnD hangs in MT Refresh()ing
Next Topic: Linux MT problems with time functions
Goto Forum:
  


Current Time: Thu Aug 28 08:55:27 CEST 2025

Total time taken to generate the page: 0.07385 seconds