U++ framework
Do not panic. Ask here before giving up.

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: Mon May 04 23:54:01 GMT+2 2026

Total time taken to generate the page: 0.00637 seconds