ReXGlue SDK
Loading...
Searching...
No Matches
rex::platform::Thread Class Referenceabstract

#include <rex/platform/thread.h>

Inheritance diagram for rex::platform::Thread:
[legend]

Classes

struct  CreationParameters

Public Types

using RedirectFilter = bool (*)(u64 pc, void* context)

Public Member Functions

virtual u32 GetSystemID () const =0
const std::string & GetName () const
virtual void SetName (std::string name)
virtual i32 GetPriority ()=0
virtual void SetPriority (i32 new_priority)=0
virtual u64 GetAffinityMask ()=0
virtual void SetAffinityMask (u64 new_affinity_mask)=0
virtual void QueueUserCallback (rex::MoveOnlyFunction< void()> callback)=0
virtual bool Resume (u32 *out_previous_suspend_count=nullptr)=0
virtual bool Suspend (u32 *out_previous_suspend_count=nullptr)=0
virtual bool Redirect (RedirectFilter filter, void *context, void(*target)())=0
virtual bool SuspendIf (RedirectFilter filter, void *context)=0
Public Member Functions inherited from rex::platform::WaitHandle
virtual void * GetNativeHandle () const =0

Static Public Member Functions

static std::unique_ptr< Thread > Create (CreationParameters params, rex::MoveOnlyFunction< void()> start_routine)
static Thread * GetCallingThread ()
static void Exit (int exit_code)

Protected Attributes

std::string name_

Detailed Description

Thread object modeled on the Win32 thread.

Member Typedef Documentation

◆ RedirectFilter

using rex::platform::Thread::RedirectFilter = bool (*)(u64 pc, void* context)

Decides whether a stopped thread is acted on.

Parameters
pcThe instruction pointer of the stopped thread.
contextThe context passed to Redirect or SuspendIf.

Member Function Documentation

◆ Create()

std::unique_ptr< Thread > rex::platform::Thread::Create ( CreationParameters params,
rex::MoveOnlyFunction< void()> start_routine )
static

Creates a thread that runs start_routine.

Returns
The thread, or null on failure.

◆ Exit()

void rex::platform::Thread::Exit ( int exit_code)
static

Ends the calling thread without running destructors, signaling the thread object. Does not return.

◆ GetAffinityMask()

virtual u64 rex::platform::Thread::GetAffinityMask ( )
pure virtual

Returns the processor affinity mask. The mask has one bit per logical processor the thread may run on.

◆ GetCallingThread()

Thread * rex::platform::Thread::GetCallingThread ( )
static

Returns the Thread object of the calling thread, wrapping threads Create did not start.

◆ QueueUserCallback()

virtual void rex::platform::Thread::QueueUserCallback ( rex::MoveOnlyFunction< void()> callback)
pure virtual

Queues a user callback. Callbacks run in FIFO order when the thread enters an alertable wait, which then returns WaitResult::kUserCallback.

◆ Redirect()

virtual bool rex::platform::Thread::Redirect ( RedirectFilter filter,
void * context,
void(* target )() )
pure virtual

Makes the thread call target in place of its current instruction when filter accepts it. Filter runs while the thread is stopped, so it must not lock or allocate.

Parameters
filterCalled with the instruction pointer of the stopped thread.
targetCalled on the thread. It never returns.
Returns
True when the thread now runs target.

◆ Resume()

virtual bool rex::platform::Thread::Resume ( u32 * out_previous_suspend_count = nullptr)
pure virtual

Decrements the suspend count. The thread runs again at 0.

Parameters
out_previous_suspend_countReceives the previous count, may be null.

◆ SetAffinityMask()

virtual void rex::platform::Thread::SetAffinityMask ( u64 new_affinity_mask)
pure virtual

Sets the processor affinity mask, a subset of the process affinity mask.

Parameters
new_affinity_mask1 bit per logical processor the thread may run on.

◆ SetName()

virtual void rex::platform::Thread::SetName ( std::string name)
inlinevirtual

Names the thread for debuggers and logs.

◆ SetPriority()

virtual void rex::platform::Thread::SetPriority ( i32 new_priority)
pure virtual

Sets the thread priority.

Parameters
new_priorityUsually a ThreadPriority value.

◆ Suspend()

virtual bool rex::platform::Thread::Suspend ( u32 * out_previous_suspend_count = nullptr)
pure virtual

Increments the suspend count and suspends the thread.

Parameters
out_previous_suspend_countReceives the previous count, may be null.

◆ SuspendIf()

virtual bool rex::platform::Thread::SuspendIf ( RedirectFilter filter,
void * context )
pure virtual

Suspends the thread when filter accepts its current instruction. Filter runs while the thread is stopped, so it must not lock or allocate.

Parameters
filterCalled with the instruction pointer of the stopped thread.
Returns
True when the thread is now suspended and its suspend count went up by 1.

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