Minetest 5.10.0-dev
 
Loading...
Searching...
No Matches
LambdaThread Class Reference

Class returned by runInThread. More...

#include <lambda.h>

+ Inheritance diagram for LambdaThread:
+ Collaboration diagram for LambdaThread:

Public Member Functions

void rethrow ()
 Re-throw a caught exception, if any. Can only be called after thread exit.
 
- Public Member Functions inherited from Thread
 Thread (const std::string &name="")
 
virtual ~Thread ()
 
bool start ()
 
bool stop ()
 
bool wait ()
 
bool isCurrentThread ()
 
bool isRunning ()
 
bool stopRequested ()
 
std::thread::id getThreadId ()
 
bool getReturnValue (void **ret)
 
bool bindToProcessor (unsigned int proc_number)
 
bool setPriority (int prio)
 

Private Member Functions

 LambdaThread (const std::string &name="")
 
void * run ()
 
bool start ()
 

Private Attributes

std::function< void()> m_fn
 
std::exception_ptr m_exptr
 

Friends

std::unique_ptr< LambdaThreadrunInThread (const std::function< void()> &fn, const std::string &thread_name="")
 Run a lambda in a separate thread.
 

Additional Inherited Members

- Static Public Member Functions inherited from Thread
static ThreadgetCurrentThread ()
 
static void setName (const std::string &name)
 
static unsigned int getNumberOfProcessors ()
 
- Protected Attributes inherited from Thread
std::string m_name
 

Detailed Description

Class returned by runInThread.

Provides the usual thread methods along with rethrow().

Constructor & Destructor Documentation

◆ LambdaThread()

LambdaThread::LambdaThread ( const std::string & name = "")
inlineprivate

Member Function Documentation

◆ rethrow()

void LambdaThread::rethrow ( )
inline

Re-throw a caught exception, if any. Can only be called after thread exit.

References Thread::isRunning(), m_exptr, and sanity_check.

+ Here is the call graph for this function:

◆ run()

void * LambdaThread::run ( )
inlineprivatevirtual

Implements Thread.

References m_exptr, and m_fn.

◆ start()

bool Thread::start ( )
private

Friends And Related Symbol Documentation

◆ runInThread

std::unique_ptr< LambdaThread > runInThread ( const std::function< void()> & fn,
const std::string & thread_name = "" )
friend

Run a lambda in a separate thread.

Exceptions will be caught.

Parameters
fnfunction to run
thread_namename for thread
Returns
thread object of type LambdaThread

Member Data Documentation

◆ m_exptr

std::exception_ptr LambdaThread::m_exptr
private

Referenced by rethrow(), and run().

◆ m_fn

std::function<void()> LambdaThread::m_fn
private

Referenced by run().


The documentation for this class was generated from the following file: