Boost logo

Boost Users :

Subject: Re: [Boost-users] Custom services using boost::asio
From: Boris Schaeling (boris_at_[hidden])
Date: 2011-08-22 17:03:47


On Tue, 16 Aug 2011 16:03:49 +0200, Allan Nielsen <a_at_[hidden]> wrote:

Hi Allan,

> [...]Using glib::source I could register an interface where two function
> is
> called:
>
> bool prepare (int &timeout);
> bool dispatch (sigc::slot_base *slot);
>
> Prepare could set a time out identifying how much time should elapse
> before
> dispatch is ready to process an event.
>
> When the time is passed, the glib main loop will call the dispatch
> function,
> where I then can process the internal events.
>
> How can this be implemented in boost::asio io_service?
>
> I have look at the section 7.5 in
> http://en.highscore.de/cpp/boost/asio.htmlbut he is using a thread and
> a blocking call. Using a thread is not a
> solution in my case.
>
> I would rather like either polling, or some kind of scheduling...
>
> I any body has some hints, examples, advices it would be most
> appreciated.

a thread is really a last resort. The ideal case is to use the very same
event loop in Boost.Asio. That's typically IOCP on Windows and select() on
POSIX. If you know that you can plug into those system calls you can use
the Windows- and POSIX-specific classes. It all depends on whether you can
get a file descriptor or HANDLE from glib::source to use with Boost.Asio?

Boris


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net