Boost logo

Boost :

Subject: Re: [boost] [thread] Request review of new synchronisation object, boost::permit<>
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2014-05-05 09:59:28


On 5 May 2014 at 11:03, microcai wrote:

> >> > A non-consuming permit looks quite like a Win32 event object yes, except
> >> > it has stronger guarantees useful for many-waiter many-signaller
> >> > situations.
>
> asio::windows::object_handle permit(io_service, CreateEvent(0,1,00));
>
> permit.wait();
>
> permit.async_wait( []{ do some thing here} ) ;

Equivalent with permits:

boost::permit_nc permit;
int fds[2];
pipe(fds);
pthread_permitnc_associate_fd(permit.native_handle(), fds);
asio::posix::stream_descriptor input(ioservice, fd[0]),
output(ioservice, fd[1]);
input.async_wait([] { do something here } );

I haven't checked this code, but something close should work. The
point is you can associate the state of a fd with a non-consuming
permit.

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