thread: fix compilation for linux specialisations

This commit is contained in:
Danny Robson 2018-08-16 12:10:05 +10:00
parent 6c5a7cc5fa
commit 3adbfae057
7 changed files with 14 additions and 21 deletions

View File

@ -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 ()

View File

@ -53,7 +53,7 @@ event::wait (void)
///////////////////////////////////////////////////////////////////////////////
int
event::notify (void)
event::notify_all (void)
{
return notify (std::numeric_limits<int>::max ());
}

View File

@ -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);

View File

@ -1,4 +1,4 @@
#include "platform.hpp"
#include "../platform.hpp"
#if defined(PLATFORM_LINUX)
#include "flag_futex.hpp"

View File

@ -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);
}

View File

@ -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;

View File

@ -1,4 +1,4 @@
#include "platform.hpp"
#include "../platform.hpp"
#if defined(PLATFORM_LINUX)
#include "semaphore_linux.hpp"