xrpld
Loading...
Searching...
No Matches
beast::unit_test::Thread Class Reference

Replacement for std::thread that handles exceptions in unit tests. More...

#include <thread.h>

Collaboration diagram for beast::unit_test::Thread:

Public Types

using id = std::thread::id
using native_handle_type = std::thread::native_handle_type

Public Member Functions

 Thread ()=default
 Thread (Thread const &)=delete
Threadoperator= (Thread const &)=delete
 Thread (Thread &&other)
Threadoperator= (Thread &&other)
template<class F, class... Args>
 Thread (Suite &s, F &&f, Args &&... args)
bool joinable () const
std::thread::id getId () const
void join ()
void detach ()
void swap (Thread &other)

Static Public Member Functions

static unsigned hardwareConcurrency () noexcept

Private Member Functions

void run (std::function< void(void)> f)

Private Attributes

Suites_ = nullptr
std::thread t_

Detailed Description

Replacement for std::thread that handles exceptions in unit tests.

Definition at line 20 of file thread.h.

Member Typedef Documentation

◆ id

Definition at line 27 of file thread.h.

◆ native_handle_type

using beast::unit_test::Thread::native_handle_type = std::thread::native_handle_type

Definition at line 28 of file thread.h.

Constructor & Destructor Documentation

◆ Thread() [1/4]

beast::unit_test::Thread::Thread ( )
default

◆ Thread() [2/4]

beast::unit_test::Thread::Thread ( Thread const & )
delete

◆ Thread() [3/4]

beast::unit_test::Thread::Thread ( Thread && other)

Definition at line 35 of file thread.h.

◆ Thread() [4/4]

template<class F, class... Args>
beast::unit_test::Thread::Thread ( Suite & s,
F && f,
Args &&... args )
explicit

Definition at line 48 of file thread.h.

Member Function Documentation

◆ operator=() [1/2]

Thread & beast::unit_test::Thread::operator= ( Thread const & )
delete

◆ operator=() [2/2]

Thread & beast::unit_test::Thread::operator= ( Thread && other)

Definition at line 40 of file thread.h.

◆ joinable()

bool beast::unit_test::Thread::joinable ( ) const
nodiscard

Definition at line 58 of file thread.h.

◆ getId()

std::thread::id beast::unit_test::Thread::getId ( ) const
nodiscard

Definition at line 64 of file thread.h.

◆ hardwareConcurrency()

unsigned beast::unit_test::Thread::hardwareConcurrency ( )
staticnoexcept

Definition at line 70 of file thread.h.

◆ join()

void beast::unit_test::Thread::join ( )

Definition at line 76 of file thread.h.

◆ detach()

void beast::unit_test::Thread::detach ( )

Definition at line 83 of file thread.h.

◆ swap()

void beast::unit_test::Thread::swap ( Thread & other)

Definition at line 89 of file thread.h.

◆ run()

void beast::unit_test::Thread::run ( std::function< void(void)> f)
private

Definition at line 97 of file thread.h.

Member Data Documentation

◆ s_

Suite* beast::unit_test::Thread::s_ = nullptr
private

Definition at line 23 of file thread.h.

◆ t_

std::thread beast::unit_test::Thread::t_
private

Definition at line 24 of file thread.h.