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