[Tnfox-discussion] Re: [Foxgui-users]Wait till system() ends?

View: New views
1 Messages — Rating Filter:   Alert me  

Parent Message unknown [Tnfox-discussion] Re: [Foxgui-users]Wait till system() ends?

by Niall Douglas :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 25 Feb 2006 at 10:10, The Devils Jester wrote:

> My child app has a list of thousands of tasks it must perform, after each
> task it needs to send a message to the parent to ask permission to do the
> next task (or possibly skip ahead, or repeat a task).

A simple synchronous IPC msg would be ideal here (msg + ack).

> struct A_Child_Event()
> {
> char event_type;
> char* event_data;
> long int event_timestamp;
> A_Parent_Event *response;
> }

In TnFOX you would subclass FXIPCMsg for each message and reply
(ack). So event_type would be a specific class type containing any
data you like, including a FXTime (which is a time & date class in
TnFOX rather than a time_t)

> The parent app will sit in a loop, checking this predetermined pointer for
> info from the child (as long as I could do this and still keep FOX
> refreshing).

In TnFOX, you can choose either to poll for messages or have a
dedicated handler thread. The hander thread basically abstracts down
to a switch() statement in which you can deal with almost all
messages immediately. For example. you can update a FOX control with
a new value by posting an async message to the event loop for the
control's thread.

> If I could only make the system aware of the new event _without_ a loop like
> this it would be much nicer.
>
> The child app needs to do its tasks, and _fast_, it doesnt have time to wait
> for the parent to 'find' the event message and send a reponse.  (Plus the
> large loop of the parent looking for a event would drop the speed of the
> child considerably and its a CPU intensive task.)

Well, TnFOX's IPC mechanism is faster than CORBA, so it's fast. It's
also O(1) complexity with both number of messages handled and
sent/received.

BTW you should have virtually no code changes when switching from FOX
to TnFOX. Just recompile. You can even keep all your existing
FXMutex/FXThread etc. stuff by enabling the FOX compatibility layer.
You're better moving to TnFOX's native stuff eventually though - it
can do stuff like deferred thread cancellation which FOX can't.

For more info, see
http://tnfox.sourceforge.net/TnFOX/html/class_f_x_1_1_f_x_i_p_c_channe
l.html or check TestIPC in the test suite.

Cheers,
Niall





-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Tnfox-discussion mailing list
Tnfox-discussion@...
https://lists.sourceforge.net/lists/listinfo/tnfox-discussion