thread: fix compilation for linux specialisations
This commit is contained in:
parent
6c5a7cc5fa
commit
3adbfae057
@ -88,8 +88,8 @@ list (
|
||||
##-----------------------------------------------------------------------------
|
||||
if (LINUX)
|
||||
list (APPEND UTIL_FILES
|
||||
thread/event_linux.cpp
|
||||
thread/flag_linux.cpp
|
||||
thread/event_futex.cpp
|
||||
thread/flag_futex.cpp
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
@ -53,7 +53,7 @@ event::wait (void)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
event::notify (void)
|
||||
event::notify_all (void)
|
||||
{
|
||||
return notify (std::numeric_limits<int>::max ());
|
||||
}
|
||||
|
@ -39,7 +39,9 @@ namespace cruft::thread {
|
||||
void wait (void);
|
||||
|
||||
/// wake all threads that are waiting
|
||||
int notify (void);
|
||||
int notify_one (void);
|
||||
|
||||
int notify_all (void);
|
||||
|
||||
/// wait `count' threads that are waiting
|
||||
int notify (int count);
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "platform.hpp"
|
||||
#include "../platform.hpp"
|
||||
|
||||
#if defined(PLATFORM_LINUX)
|
||||
#include "flag_futex.hpp"
|
||||
|
@ -55,20 +55,11 @@ flag::wait (void)
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
int
|
||||
flag::notify (void)
|
||||
{
|
||||
return notify (std::numeric_limits<int>::max ());
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int
|
||||
flag::notify (int count)
|
||||
void
|
||||
flag::notify_all (void)
|
||||
{
|
||||
value = 1;
|
||||
auto res = sys_futex (&value, FUTEX_WAKE, count, nullptr, nullptr, 0);
|
||||
auto res = sys_futex (&value, FUTEX_WAKE, std::numeric_limits<int>::max (), nullptr, nullptr, 0);
|
||||
if (res < 0)
|
||||
posix::error::throw_code ();
|
||||
return cruft::cast::narrow<int> (res);
|
||||
}
|
||||
|
@ -22,10 +22,10 @@ namespace cruft::thread {
|
||||
void wait (void);
|
||||
|
||||
/// wake all the threads waiting on the flag
|
||||
void notify (void);
|
||||
void notify_one (void);
|
||||
|
||||
/// wake at most 'n' threads waiting on the flag
|
||||
void notify (int);
|
||||
/// wake all threads waiting on the flag
|
||||
void notify_all (void);
|
||||
|
||||
private:
|
||||
std::atomic<int> value;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "platform.hpp"
|
||||
#include "../platform.hpp"
|
||||
|
||||
#if defined(PLATFORM_LINUX)
|
||||
#include "semaphore_linux.hpp"
|
||||
|
Loading…
Reference in New Issue
Block a user