Re: [Iup-users] Firing an event from another thread
Brought to you by:
scuri
From: Ross B. <Ross@CheshireEng.com> - 2008-11-26 03:50:06
|
At 06:58 PM 11/25/2008, Antonio Scuri wrote: >Maybe using: LuaTask ... Or LuaThread ... I'm currently using Lanes (http://luaforge.net/projects/lanes) for my threading model. I am being careful to only load IUP in a single thread, and to only call IUP functions from that single thread. My worker thread wants to display progress, status and results in the GUI, so I use a FIFO structure provided by Lanes to move the status from the worker thread to the GUI. The problem is to let the IUP thread know that the FIFO has data ready. >I don't think IupTimer is thread safe. You will still have to >lock the features you want to check. IupTimer isn't any more thread safe than the rest of IUP, but it does allow a background activity to execute in the same thread as the rest of the GUI. As long as the threading system allows for some kind of thread-safe data passing, then the timer's ACTION_CB callback can be used to pull data from other threads into the GUI thread. In my application, the timer's ACTION_CB function polls my various FIFOs for any available messages, and then acts on them to update values in various controls displayed in the UI. But my application also interacts with a peripheral device that can asynchronously raise events and change its status. The underlying drivers (which I cannot modify) for that device deliver those events to an application with callback functions each called on a new thread created when the event happens. I'm looking for a way to make these events visible to IUP (and hence to my application) as well. >I'll rather check these tools before changing something in IUP >regarding to threads. Mostly I was hoping that something already existed that would allow a callback coming from a system component to spontaneously generate events that IUP would dispatch to callback functions. Now that I know I won't be reinventing something that exists, I will investigate implementing the smallest possible patch to IUP that enables any thread at all to cause IUP to fire an event on its own thread. I think it is also possible that what I need to do can be implemented in a control in its own DLL without modification to IUP itself. That is likely to have the advantage (to me) of not requiring that I setup to build IUP... Either way, I will report back to the list on what I did and how it worked out. Ross Berteig Ross@CheshireEng.com Cheshire Engineering Corp. http://www.CheshireEng.com/ |