[vos-d] WxTerangreal TaskQueue question
Peter Amstutz
tetron at interreality.org
Wed Apr 4 10:08:41 EDT 2007
On Wed, Apr 04, 2007 at 12:50:10AM -0700, Ken Taylor wrote:
> Just a quickie:
>
> Most tasks in the wx version of terangreal get added to a "mainThreadTasks"
> static queue, which is handled by wxgui's Pump (a wxTimer). However, the
> goToWorldTask gets added to TaskQueue::defaultTQ. What's the difference
> between these two mechanisms for task scheduling, and why would you use one
> or the other?
The mainThreadTasks are executed by the main event loop managed by
wxWidgets. Anything that needs to interact with wxWidgets or Crystal
Space *must* run in that main event loop because neither WX nor CS are
thread safe.
However, because the event loop is also used to repaint the GUI and 3D
scene, you can't have any blocking operations in your handlers or the
application will appear to freeze. So to execute an lengthy request
(such as downloading a world) you create a task and put it in the
"default task queue", which is serviced by a thread pool. So the task
goes off and is run sometime in the future in some other thread. Also,
all event callbacks like notifyPropertyChange() are processed through
the thread pool.
This design seemed like a great idea at the time, and works reasonably
well on the server side when handling multiple independent requests.
However on the client side, where there is a lot more task dependency
and forced serialization brought on by the requirements of the libraries
as well as the need to remain responsive to the user, having a lot of
worker threads wizzing making reentrant calls into user code turned out
to be really hard to program for.
For s5 I'm working on a different approach which will be much cleaner,
which I hope to have a writeup for later today.
--
[ Peter Amstutz ][ tetron at interreality.org ][ peter.amstutz at gdit.com ]
[Lead Programmer][Interreality Project][Virtual Reality for the Internet]
[ VOS: Next Generation Internet Communication][ http://interreality.org ]
[ http://interreality.org/~tetron ][ pgpkey: pgpkeys.mit.edu 18C21DF7 ]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.interreality.org/pipermail/vos-d/attachments/20070404/81ce3a7d/attachment.pgp
More information about the vos-d
mailing list