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 » Thread based "conveyor" class for Win32
Thread based "conveyor" class for Win32 [message #12083] Wed, 10 October 2007 18:51 Go to previous message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

In my work I have rather usual task of having some queue service, processing main thread requests in background. I just finished general purpose class template for simplified handling of such a task. It`s rather young (with interface unpolished) but look at what you can do with it:
template<class T> class ConveyorThread : protected Thread
{ typedef ConveyorThread CLASSNAME;
public:
	ConveyorThread(bool enabled = true);
	virtual ~ConveyorThread();
	void Enable(bool enable = true);

	void Request(Callback1<const T &>handler, const T &request);
	void ClearAllRequests();

	void SharedEnter();
	void SharedLeave();

	void RequestFinish();
	int  WaitFinished();
	bool IsFinished();
}


Just add request for asyncronous processing and define handler for it - and that`s all. Rather convenient, I suppose.
Class also has guarding functions for interacting with main thread`s objects: SharedEnter/SharedLeave (for updating interface, statistics, etc).

Any suggestions, critics and recommendations is appreciated.
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: will implement a UDP class?
Next Topic: SocketEvent
Goto Forum:
  


Current Time: Fri May 10 05:27:12 CEST 2024

Total time taken to generate the page: 0.03105 seconds