Boost logo

Boost :

Subject: [boost] [thread] Request review of new synchronisation object, boost::permit<>
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2014-05-03 17:13:31


Dear Boost,

Review and commentary upon a proposed new Boost object,
boost::permit<> is invited. A quick description of their purpose:

"Permits come in two variants, consuming and non-consuming. There is
always a one-to-one relationship between the granting of a permit and
the receiving of that permit, the only difference with the
non-consuming variant is that the permit is automatically regranted
as soon as it is consumed. This leads to the only API difference to
condition variables: permit<consuming=true> provides notify_one() but
not notify_all(), whilst permit<consuming=false> provides neither and
you will have to use grant() and revoke() instead. When deciding to
substitute permits for condition variables, you will need to decide
carefully which kind of permit is the correct substitute."

"Permit objects are actually very similar to a void promise/future
i.e. they act as a reusable promise/future pair but without
transporting any value or exception state, just the permission to
proceed. This is due to their original design intention, which was as
a promise/future equivalent for C11 (see below for their history, and
note that the original C API is available in the boost::c_permit
namespace and documentation can be found at
https://ci.nedprod.com/job/Boost.Thread%20Build%20Documentation/lastSu
ccessfulBuild/artifact/boost-trunk/boost/thread/permit/latex/pthread_p
ermit_reference.pdf). As such, they can be very useful for situations
where a promise/future is too heavy (permits can spin instead of
sleep, plus they need not be repeatedly constructed and destructed)."

There is lots more detail at their documentation page:
https://ci.nedprod.com/job/Boost.Thread%20Build%20Documentation/Boost.
Thread_Documentation/libs/thread/doc/html/thread/synchronization/permi
t_ref.html

Source code of Permit containing fork of Boost.Thread:

https://github.com/ned14/thread/tree/permit_object

They come with a functional and load soak test suite. They work on
Windows, Linux, FreeBSD and I believe OS X.

Any other questions do ask.

Niall

-- 
Currently unemployed and looking for work in Ireland.
Work Portfolio: http://careers.stackoverflow.com/nialldouglas/



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