Minecraft Community Edition 0.1.0
Loading...
Searching...
No Matches
mce::Thread Class Reference

Lightweight high-level thread wrapper. More...

#include <Thread.hpp>

Public Member Functions

template<typename F>
 Thread (QEventBus &qBus, F function)
 Construct a Thread from a generic callable (lambda, functor, function pointer).
template<typename C>
 Thread (QEventBus &qBus, void(C::*function)(), C *object)
 Construct a Thread that will call a parameterless member function.
template<typename C, typename... Args>
 Thread (QEventBus &qBus, void(C::*function)(), C *object, Args &&... args)
 Construct a Thread that will call a member function with arguments.
 ~Thread ()
 Destructor; cleans up stored callable and implementation pointer.
void launch ()
 Start execution of the stored callable on a new thread.
void wait ()
 Block until the thread has finished executing.

Friends

class ThreadImpl

Detailed Description

Lightweight high-level thread wrapper.

Stores a pointer to a platform-specific implementation (ThreadImpl) and a type-erased callable adapter (ThreadFunc) representing the entry point. Use the constructors to create a Thread from lambdas, functors, member functions, or member functions with arguments.

Constructor & Destructor Documentation

◆ Thread() [1/3]

template<typename F>
mce::Thread::Thread ( QEventBus & qBus,
F function )
inline

Construct a Thread from a generic callable (lambda, functor, function pointer).

Template Parameters
FType of the callable.
Parameters
qBusReference to the QEventBus used for thread lifecycle events.
functionThe callable to execute when the thread runs.

◆ Thread() [2/3]

template<typename C>
mce::Thread::Thread ( QEventBus & qBus,
void(C::* function )(),
C * object )
inline

Construct a Thread that will call a parameterless member function.

Template Parameters
CClass type owning the member function.
Parameters
qBusReference to the QEventBus used for thread lifecycle events.
functionPointer to the member function to invoke.
objectPointer to the object instance on which to invoke the member function.

◆ Thread() [3/3]

template<typename C, typename ... Args>
mce::Thread::Thread ( QEventBus & qBus,
void(C::* function )(),
C * object,
Args &&... args )
inline

Construct a Thread that will call a member function with arguments.

Template Parameters
CClass type owning the member function.
ArgsTypes of the arguments to forward when invoking the member function.
Parameters
qBusReference to the QEventBus used for thread lifecycle events.
functionPointer to the member function to invoke.
objectPointer to the object instance on which to invoke the member function.
argsArguments to forward to the member function when the thread runs.

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