Boost logo

Boost :

From: simon meiklejohn (simon_at_[hidden])
Date: 2005-12-13 13:50:38

Chris and Thore,

----- Original Message -----
From: "Thore Karlsen" <sid_at_[hidden]>
Newsgroups: gmane.comp.lib.boost.devel
Sent: Wednesday, December 14, 2005 4:53 AM
Subject: Re: Asio formal review

> On Tue, 13 Dec 2005 20:34:45 +1000, Matthew Vogt <mattvogt_at_[hidden]>
> wrote:
>>I wonder how the demuxer would be incoporated into a GUI event-loop-based
>>program, particularly in toolkits which mandate that GUI updates can occur
>>a single thread only?
> I was wondering the same thing. For Windows clients I like
> WSAAsyncSelect() and just driving the sockets through the GUI message
> loop, since I don't have to worry about threading issues. Another reason
> I like it is because I can have several dozen windows open, each one a
> separate component. I really can't afford to have several threads (at
> least one to drive the demuxing and one for the async resolves) created
> for each window, and I would prefer not to require each window to have
> to register with a shared demuxing thread.

Hope Chris doesnt mind me jumping in here.

background -
In win32 you can send things to the gui thread from any other thread by
posting a message to _any_ window. The windows procedure associated with
that window will be called with that message in the gui thread (or more
in the thread on which the window was created) provided that thread has
a message pump running.

use with asio
Its feasible to use this to create dispatcher class, similar to
asio::locking_dispatcher which can be used to send function objects to
be executed in the gui thread (call this asio::gui_dispatcher). This
component internally creates a hidden window. A call to or dispatch() queues the function object
and posts a message to the hidden window. The windows proc
associated with the window then unqueues the function object
and calls it.

I dont think you need to register every window with asio. Just
create one gui_dispatcher and use it to wrap your Handlers before
passing them to asio socket functions.

(theres a zip in the vault under Concurrent Programming
that does something like this but not as an asio::dispatcher model)



Boost list run by bdawes at, gregod at, cpdaniel at, john at