Boost logo

Boost :

Subject: Re: [boost] [ANN] Boost.UI - a new C++ GUI library
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-09-28 22:06:07


>>> I don't like the fact that it introduces its own event loop that I have no
>>> control on.
>
>> This loop is designed to interact with user, all GUI librararies have
>> it. When user press button key he should wait while your loop have a
>> time to handle users request?
>
> I haven't looked over your library at all yet, but I have bumped into
> the problem of trying to integrate application code with an
> inaccessible main loop.
>
> Instead of providing your own main loop, you might consider using an
> Asio io_service as your main event loop, and exposing (a subset of)
> its API to your own library consumers. That would give you a certain
> level of extensibility right out of the box.

Another option is to copy AFIO's io_service design
https://ned14.github.io/afio/classafio__v2__xxx_1_1io__service.html:

- Don't implement a main loop, implement a function e.g. run() which
dispatches exactly one pending event, returning true if there was an
event processed.
- Said run() also comes in run_until(deadline) form, where deadline can
be "now" i.e. poll for an event, if one present dispatch it, else return
immediately.
- A post() routine lets any thread cause some user supplied callable to
be executed in the run().

Thence the programmer may write:

// Dispatch events, blocking if no new events, returning false if
// no work pending.
while(service.run());

Or they might write:

// Polling implementation, exits loop if no work pending
while(service.run_until(0))
{
  do other work;
}

The point is to open up your event dispatch so it can coexist with
whatever existing system the user is already using.

Niall

-- 
ned Productions Limited Consulting
http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk