VEXcode Doxygen
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...

#include <vex_thread.h>

Public Member Functions

 thread (int(*callback)(void))
 Creates a thread object. More...
 
 thread (int(*callback)(void *), void *arg)
 Creates a thread object. More...
 
 thread (void(*callback)(void))
 Creates a thread object. More...
 
 thread (void(*callback)(void *), void *arg)
 Creates a thread object. More...
 
int32_t get_id ()
 Gets the ID of the thread. More...
 
void join ()
 Waits for the other thread to finish its execution. More...
 
void detach ()
 Permits the thread to execute from the thread handle. More...
 
bool joinable ()
 Checks whether the thread is joinable. 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 void interruptAll ()
 Stop all threads except main. More...
 
static int32_t hardware_concurrency ()
 Gets the number of concurrent threads supported by the hardware. 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.

@prog_lang{pro}

Constructor & Destructor Documentation

◆ thread() [1/4]

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

Creates a thread object.

@prog_lang{pro} @drawer_cat{constructor|none}

Parameters
callbackA reference to a function.

◆ thread() [2/4]

vex::thread::thread ( int(*)(void *)  callback,
void *  arg 
)

Creates a thread object.

@prog_lang{pro} @drawer_cat{none}

Parameters
callbackA reference to a function.
argA void pointer that is passed to the callback.

◆ thread() [3/4]

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

Creates a thread object.

@prog_lang{pro} @drawer_cat{constructor|none}

Parameters
callbackA reference to a function.

◆ thread() [4/4]

vex::thread::thread ( void(*)(void *)  callback,
void *  arg 
)
inline

Creates a thread object.

@prog_lang{pro} @drawer_cat{none}

Parameters
callbackA reference to a function.
argA void pointer that is passed to the callback.

Member Function Documentation

◆ detach()

void vex::thread::detach ( )
inline

Permits the thread to execute from the thread handle.

@prog_lang{pro} @drawer_cat{action|none} @block_sig{Thread.detach();}

◆ get_id()

int32_t vex::thread::get_id ( )

Gets the ID of the thread.

@prog_lang{pro} @drawer_cat{sensing|none} @block_sig{Thread.get_id()}

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

◆ hardware_concurrency()

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

Gets the number of concurrent threads supported by the hardware.

@prog_lang{pro} @drawer_cat{sensing|none} @block_sig{Thread.hardware_concurrency()}

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

◆ interrupt()

void vex::thread::interrupt ( )

Stops the thread.

@prog_lang{pro} @drawer_cat{action|none} @block_sig{Thread.interrupt();}

◆ interruptAll()

static void vex::thread::interruptAll ( )
static

Stop all threads except main.

@prog_lang{pro} @drawer_cat{none} @block_sig{Thread.interruptAll();}

◆ join()

void vex::thread::join ( )

Waits for the other thread to finish its execution.

@prog_lang{pro} @drawer_cat{action|none} @block_sig{Thread.join();}

◆ joinable()

bool vex::thread::joinable ( )

Checks whether the thread is joinable.

@prog_lang{pro} @drawer_cat{sensing|none} @block_sig{Thread.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.

@prog_lang{pro} @drawer_cat{setting|none} @block_sig{Thread.native_handle();}

◆ priority()

int32_t vex::thread::priority ( )

Gets the priority of the thread.

@prog_lang{pro} @drawer_cat{sensing|none} @block_sig{Thread.priority()}

Returns
Returns the priority of the thread as an integer.

◆ setPriority()

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

Sets the priority of the thread.

@prog_lang{pro} @drawer_cat{setting|none} @block_sig{thread.setPriority(1);}

Parameters
priorityThe priority of the thread to be set to.

◆ swap() [1/2]

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

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

@prog_lang{pro} @drawer_cat{action|none} @block_sig{Thread.swap(thread1);}

Parameters
__tThe thread to swap to.

◆ swap() [2/2]

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

Swaps two threads specified in the parameters.

@prog_lang{pro} @drawer_cat{action|none} @block_sig{Thread.swap(thread1, thread2);}

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.

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