forked from Alepha/Alepha
Rehabilitate the Thread
type and test.
This commit is contained in:
@ -31,6 +31,7 @@ add_subdirectory( Exception.test )
|
|||||||
add_subdirectory( word_wrap.test )
|
add_subdirectory( word_wrap.test )
|
||||||
add_subdirectory( string_algorithms.test )
|
add_subdirectory( string_algorithms.test )
|
||||||
add_subdirectory( tuplize_args.test )
|
add_subdirectory( tuplize_args.test )
|
||||||
|
add_subdirectory( Thread.test )
|
||||||
|
|
||||||
# Sample applications
|
# Sample applications
|
||||||
add_executable( example example.cc )
|
add_executable( example example.cc )
|
||||||
|
28
Thread.h
28
Thread.h
@ -4,9 +4,9 @@ static_assert( __cplusplus > 2020'99 );
|
|||||||
|
|
||||||
#include <Alepha/Alepha.h>
|
#include <Alepha/Alepha.h>
|
||||||
|
|
||||||
#include <Alepha/boost_path/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
#include <Alepha/boost_path/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#include <Alepha/boost_path/thread/condition_variable.hpp>
|
#include <boost/thread/condition_variable.hpp>
|
||||||
|
|
||||||
#include <Alepha/Exception.h>
|
#include <Alepha/Exception.h>
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ namespace Alepha::Hydrogen
|
|||||||
{
|
{
|
||||||
callable();
|
callable();
|
||||||
}
|
}
|
||||||
catch( const boost_ns::thread_interrupted & )
|
catch( const boost::thread_interrupted & )
|
||||||
{
|
{
|
||||||
std::lock_guard lock( access );
|
std::lock_guard lock( access );
|
||||||
if( not notification ) throw;
|
if( not notification ) throw;
|
||||||
@ -63,7 +63,7 @@ namespace Alepha::Hydrogen
|
|||||||
namespace exports
|
namespace exports
|
||||||
{
|
{
|
||||||
class ConditionVariable
|
class ConditionVariable
|
||||||
: private boost_ns::condition_variable
|
: private boost::condition_variable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using condition_variable::notify_all;
|
using condition_variable::notify_all;
|
||||||
@ -89,17 +89,17 @@ namespace Alepha::Hydrogen
|
|||||||
{
|
{
|
||||||
template< typename Clock, typename Duration >
|
template< typename Clock, typename Duration >
|
||||||
void
|
void
|
||||||
sleep_until( const boost_ns::chrono::time_point< Clock, Duration > &abs_time )
|
sleep_until( const boost::chrono::time_point< Clock, Duration > &abs_time )
|
||||||
{
|
{
|
||||||
notification.check_interrupt( [&]{ boost_ns::this_thread::sleep_until( abs_time ); } );
|
notification.check_interrupt( [&]{ boost::this_thread::sleep_until( abs_time ); } );
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
template< typename Rep, typename Period >
|
template< typename Rep, typename Period >
|
||||||
void
|
void
|
||||||
sleep_for( const boost_ns::chrono::duration< Rep, Period > &rel_time )
|
sleep_for( const boost::chrono::duration< Rep, Period > &rel_time )
|
||||||
{
|
{
|
||||||
notification.check_interrupt( [&]( boost_ns::this_thread::sleep_until( rel_time ); } );
|
notification.check_interrupt( [&]( boost::this_thread::sleep_until( rel_time ); } );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ namespace Alepha::Hydrogen
|
|||||||
namespace exports
|
namespace exports
|
||||||
{
|
{
|
||||||
class Thread
|
class Thread
|
||||||
: ThreadNotification, boost_ns::thread
|
: ThreadNotification, boost::thread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
template< typename Callable >
|
template< typename Callable >
|
||||||
@ -153,10 +153,10 @@ namespace Alepha::Hydrogen
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using Mutex= boost_ns::mutex;
|
using Mutex= boost::mutex;
|
||||||
using boost_ns::mutex;
|
using boost::mutex;
|
||||||
using boost_ns::unique_lock;
|
using boost::unique_lock;
|
||||||
using boost_ns::lock_guard;
|
using boost::lock_guard;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
3
Thread.test/CMakeLists.txt
Normal file
3
Thread.test/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
link_libraries( boost_thread )
|
||||||
|
|
||||||
|
unit_test( thread )
|
@ -1,10 +0,0 @@
|
|||||||
CXXFLAGS+= -std=c++2a -I ../
|
|
||||||
CXXFLAGS+= -g -O0
|
|
||||||
CXX=clang++-12
|
|
||||||
|
|
||||||
CXXFLAGS+= -Wno-inline-namespace-reopened-noninline
|
|
||||||
CXXFLAGS+= -Wno-unused-comparison
|
|
||||||
|
|
||||||
LDLIBS+= -lboost_thread -lpthread
|
|
||||||
|
|
||||||
all: thread
|
|
@ -6,7 +6,7 @@ static_assert( __cplusplus > 2020'99 );
|
|||||||
|
|
||||||
#include <Alepha/Testing/test.h>
|
#include <Alepha/Testing/test.h>
|
||||||
#include <Alepha/Testing/TableTest.h>
|
#include <Alepha/Testing/TableTest.h>
|
||||||
#include <Alepha/Utility/evaluation.h>
|
#include <Alepha/Utility/evaluation_helpers.h>
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -36,7 +36,7 @@ namespace
|
|||||||
}
|
}
|
||||||
catch( const boost::thread_interrupted & )
|
catch( const boost::thread_interrupted & )
|
||||||
{
|
{
|
||||||
std::cerr << "SHIT! We didn't get intercepted!" << std::endl;
|
std::cerr << "OOPS! We didn't get intercepted!" << std::endl;
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
catch( const MyNotification &n )
|
catch( const MyNotification &n )
|
||||||
|
Reference in New Issue
Block a user