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:
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.
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:
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.
Interesting idea. Is there anything that prevents using Semaphore instead of events there? (The problem is that your code is win32 specific).
Mindtraveller Messages: 917 Registered: August 2007 Location: Russia, Moscow rgn.
Experienced Contributor
I just recollected the cause of using Windows objects instead of Semaphore class: the need of WaitForMultipleObjects call. Also, I was needed for testing of object state with WaitForSingleObject(finishEvent, 0)
I just recollected the cause of using Windows objects instead of Semaphore class: the need of WaitForMultipleObjects call. Also, I was needed for testing of object state with WaitForSingleObject(finishEvent, 0)
Mindtraveller Messages: 917 Registered: August 2007 Location: Russia, Moscow rgn.
Experienced Contributor
Recently I finished project. It included new upgraded version of ConveyorThread and brand new RS232Thread class.
RS232Thread is really advanced helper class useful i.e. for industrial automation, when it`s necessary to have some good tool for programming COM-port (RS232) i/o.
I`d like to contribute these classes into some package into U++. For now, they are targeted for Win32 only. It is due to Mutex and Semaphore limitations listed above.
I`m no professional in Linux, but if these base sync classes functionality extended, I`ll try to write complete multiplatform ConveyorThread and RS232Thread.
Is it possible to add necessary functionality to these classes?
Mindtraveller wrote on Wed, 12 December 2007 17:16
Recently I finished project. It included new upgraded version of ConveyorThread and brand new RS232Thread class.
RS232Thread is really advanced helper class useful i.e. for industrial automation, when it`s necessary to have some good tool for programming COM-port (RS232) i/o.
I`d like to contribute these classes into some package into U++. For now, they are targeted for Win32 only. It is due to Mutex and Semaphore limitations listed above.
I`m no professional in Linux, but if these base sync classes functionality extended, I`ll try to write complete multiplatform ConveyorThread and RS232Thread.
Is it possible to add necessary functionality to these classes?
Maybe it will be necessarry to just #ifdef PLATFORM_LINUX and use Linux API here...
zsolt Messages: 693 Registered: December 2005 Location: Budapest, Hungary
Contributor
Mindtraveller wrote on Wed, 12 December 2007 23:16
Recently I finished project. It included new upgraded version of ConveyorThread and brand new RS232Thread class.
RS232Thread is really advanced helper class useful i.e. for industrial automation, when it`s necessary to have some good tool for programming COM-port (RS232) i/o.
I`d like to contribute these classes into some package into U++. For now, they are targeted for Win32 only. It is due to Mutex and Semaphore limitations listed above.
I think, you can post it here and a good Linux programmer could finish it. These classes seems to be very interesting
Mindtraveller Messages: 917 Registered: August 2007 Location: Russia, Moscow rgn.
Experienced Contributor
Recently I`ve been thinking about implementing Mutex and Semaphore with additional functionality and how to do it the best way.
And that`s my suggestion: it is possible to make these classes Multithreading POSIX API based. It will work OK for Linux version. And for Win32 the same functions will be mapped by POSIX Threads for Win32 library calls. Here`s library description: <a href="http://sourceware.org/pthreads-win32/conformance.html"></a>
This will unify, ease debugging and reading of code.