Loading...
Searching...
No Matches
mce::core::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::core::Thread::Thread | ( | QEventBus & | qBus,
|  | F | function )

inline

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

Template Parameters

  F | Type of the callable.

Parameters

  qBus | Reference to the QEventBus used for thread lifecycle events.
  function | The callable to execute when the thread runs.

## Thread() [2/3]

template<typename C>

mce::core::Thread::Thread | ( | QEventBus & | qBus,
|  | void(C::* | function )(),
|  | C * | object )

inline

Construct a Thread that will call a parameterless member function.

Template Parameters

  C | Class type owning the member function.

Parameters

  qBus | Reference to the QEventBus used for thread lifecycle events.
  function | Pointer to the member function to invoke.
  object | Pointer to the object instance on which to invoke the member function.

## Thread() [3/3]

template<typename C, typename ... Args>

mce::core::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

  C | Class type owning the member function.
  Args | Types of the arguments to forward when invoking the member function.

Parameters

  qBus | Reference to the QEventBus used for thread lifecycle events.
  function | Pointer to the member function to invoke.
  object | Pointer to the object instance on which to invoke the member function.
  args | Arguments to forward to the member function when the thread runs.

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

- Minecraft-Community-Edition/Core/Thread.hpp
- Minecraft-Community-Edition/Core/Thread.cpp