job/semaphore: add multi-release
This commit is contained in:
parent
848b9951e8
commit
53255ca4a0
@ -34,6 +34,7 @@ namespace util::job {
|
|||||||
int acquire (void);
|
int acquire (void);
|
||||||
int acquire (int count);
|
int acquire (int count);
|
||||||
int release (void);
|
int release (void);
|
||||||
|
int release (int count);
|
||||||
|
|
||||||
auto lock (void) { return acquire (); }
|
auto lock (void) { return acquire (); }
|
||||||
auto unlock (void) { return release (); }
|
auto unlock (void) { return release (); }
|
||||||
|
@ -89,15 +89,23 @@ semaphore::acquire (void)
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
int
|
int
|
||||||
semaphore::release (void)
|
semaphore::release (int count)
|
||||||
{
|
{
|
||||||
auto res = ++m_value;
|
auto res = m_value += count;
|
||||||
if (sys_futex (&m_value, FUTEX_WAKE, 1, nullptr, nullptr, 0) < 0)
|
if (sys_futex (&m_value, FUTEX_WAKE, count, nullptr, nullptr, 0) < 0)
|
||||||
posix::error::throw_code ();
|
posix::error::throw_code ();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
int
|
||||||
|
semaphore::release (void)
|
||||||
|
{
|
||||||
|
return release (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
int
|
int
|
||||||
semaphore::value (void) const
|
semaphore::value (void) const
|
||||||
|
Loading…
Reference in New Issue
Block a user