VEX V5 C++ API
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
vex::thread Class Reference

Use this class to create and control threads. More...

Public Member Functions

 thread ()
 
 thread (void(*callback)(void))
 Creates a thread object. More...
 
 ~thread ()
 
int32_t get_id ()
 Gets the ID of the thread. More...
 
void join ()
 Waits for the other thread to finish its execution. More...
 
bool joinable ()
 Permits the thread to execute from the thread handle. More...
 
void * native_handle ()
 Gets the pointer to the native handle of the thread. More...
 
void swap (thread &__t)
 Swaps the thread IDs with another specified thread in the parameter. More...
 
void interrupt ()
 Stops the thread. More...
 
void setPriority (int32_t priority)
 Sets the priority of the thread. More...
 
int32_t priority ()
 Gets the priority of the thread. More...
 

Static Public Member Functions

static int32_t hardware_concurrency ()
 Gets the number of concurrent threads supported by the harware. More...
 
static void swap (thread &__x, thread &__y)
 Swaps two threads specified in the parameters. More...
 

Static Public Attributes

static const int32_t threadPrioritylow = 1
 
static const int32_t threadPriorityNormal = 7
 
static const int32_t threadPriorityHigh = 15
 

Detailed Description

Use this class to create and control threads.

Constructor & Destructor Documentation

◆ thread() [1/2]

vex::thread::thread ( )

◆ thread() [2/2]

vex::thread::thread ( void(*)(void)  callback)

Creates a thread object.

Parameters
callbackA reference to a function.

◆ ~thread()

vex::thread::~thread ( )

Member Function Documentation

◆ get_id()

int32_t vex::thread::get_id ( )

Gets the ID of the thread.

Returns
Returns an integer that represents the thread's ID.

◆ join()

void vex::thread::join ( )

Waits for the other thread to finish its execution.

◆ joinable()

bool vex::thread::joinable ( )

Permits the thread to execute from the thread handle.

Checks whether the thread is joinable.

Returns
Returns a true Boolean if the thread is joinable.

◆ native_handle()

void* vex::thread::native_handle ( )

Gets the pointer to the native handle of the thread.

◆ swap() [1/2]

void vex::thread::swap ( thread __t)

Swaps the thread IDs with another specified thread in the parameter.

Parameters
__tThe thread to swap to.

◆ interrupt()

void vex::thread::interrupt ( )

Stops the thread.

◆ setPriority()

void vex::thread::setPriority ( int32_t  priority)

Sets the priority of the thread.

Parameters
priorityThe priority of the thread to be set to.

◆ priority()

int32_t vex::thread::priority ( )

Gets the priority of the thread.

Returns
Returns the priority of the thread as an integer.

◆ hardware_concurrency()

static int32_t vex::thread::hardware_concurrency ( )
static

Gets the number of concurrent threads supported by the harware.

Returns
An integer that represents the amount of concurrent threads supported by the hardware.

◆ swap() [2/2]

static void vex::thread::swap ( thread __x,
thread __y 
)
inlinestatic

Swaps two threads specified in the parameters.

Parameters
__xA thread to swap with the next thread set in the parameter.
__yA thread to swap with the previous thread set in the parameter.

Member Data Documentation

◆ threadPrioritylow

const int32_t vex::thread::threadPrioritylow = 1
static

◆ threadPriorityNormal

const int32_t vex::thread::threadPriorityNormal = 7
static

◆ threadPriorityHigh

const int32_t vex::thread::threadPriorityHigh = 15
static