14#ifndef VEX_THREAD_CLASS_H
15#define VEX_THREAD_CLASS_H
31 int (* _callback)(void);
34 thread() : _callback( NULL ) {};
44 thread(
void (* callback)(
void) ) :
thread( (int (*)(void)) callback ) {}
47 static const int32_t threadPrioritylow = 1;
48 static const int32_t threadPriorityNormal = 7;
49 static const int32_t threadPriorityHigh = 15;
117 namespace this_thread {
141 template<
typename _Rep,
typename _Period>
143 sleep_for(
const std::chrono::duration<_Rep, _Period>& __rtime) {
144 if (__rtime <= __rtime.zero())
147 int __ms = std::chrono::duration_cast<std::chrono::milliseconds>(__rtime).count();
161 template<
typename _Clock,
typename _Duration>
163 sleep_until(
const std::chrono::time_point<_Clock, _Duration>& __atime)
165 auto __now = _Clock::now();
Use this class to create and control mutexes.
void lock()
Locks the mutex and blocks if the mutex is not available.
void unlock()
Unlocks the mutex.
bool try_lock()
Try to lock the mutex and returns if the mutex is not available.
Use this class to create and control threads.
void setPriority(int32_t priority)
Sets the priority of the thread.
void * native_handle()
Gets the pointer to the native handle of the thread.
thread(void(*callback)(void))
Creates a thread object.
void detach()
Permits the thread to execute from the thread handle.
void join()
Waits for the other thread to finish its execution.
int32_t get_id()
Gets the ID of the thread.
thread(int(*callback)(void))
Creates a thread object.
int32_t priority()
Gets the priority of the thread.
void interrupt()
Stops the thread.
static int32_t hardware_concurrency()
Gets the number of concurrent threads supported by the hardware.
void swap(thread &__t)
Swaps the thread IDs with another specified thread in the parameter.
bool joinable()
Checks whether the thread is joinable.
static void swap(thread &__x, thread &__y)
Swaps two threads specified in the parameters.
Bumper switch device class
void setPriority(int32_t priority)
Sets the priority of the current thread.
void sleep_for(uint32_t time)
sleep_for
void sleep_until(uint32_t time)
sleep_until
int32_t get_id()
Gets the ID of the thread.
void yield()
Suspends the current thread.
int32_t priority()
Gets the priority of the current thread.