Overview
Examples
Screenshots
Comparisons
Applications
Download
Manual
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Language
English











SourceForge.net Logo



CoWork

 

class CoWork

This class is indented as loop-parallelization tool. Whenever loop iterations are independent (they do not share any data between iterations), CoWork can be used to relatively easily spawn loop iterations over threads and thus over CPU cores. Note that previous statement does not preclude CoWork iterations to share data at all - sharing data using Mutex or similar serialization mechanisms still works. CoWork works with fixed-size global thread pool, which is created during initialization phase (first CoWork constructor called). No more thread are created or destroyed during normal work. Nesting of CoWork instances is also possible. Of course, not only loop iterations can be parallelized, whenever there are two or more actions that can run in parallel, you can use CoWork.

Single-threaded implementation simply performs all actions submitted by Do in sequence.

 

 

Public Method List

 

void Do(Callback cb)

Adds cb to be performed by any thread.

 


 

CoWork& operator&(Callback cb)

Same as Do(cb.); return *this;

 


 

void Finish()

Waits until all jobs submitted using Do (or operator&) are finished.

 

 

Destructor detail

 

~CoWork()

Invokes Finish().

 

 

Last edit by cxl on 02/24/2012. Do you want to contribute?. T++