libxr 1.0
Want to be the best embedded framework
|
线程管理类,封装 FreeRTOS 任务创建和调度 Thread management class encapsulating FreeRTOS task creation and scheduling More...
#include <thread.hpp>
Public Types | |
enum class | Priority : uint8_t { IDLE = 0 , LOW = LIBXR_PRIORITY_STEP * 1 , MEDIUM = LIBXR_PRIORITY_STEP * 2 , HIGH = LIBXR_PRIORITY_STEP * 3 , REALTIME = LIBXR_PRIORITY_STEP * 4 , NUMBER = 5 , IDLE , LOW , MEDIUM , HIGH , REALTIME , NUMBER , IDLE = 0 , LOW = 0 , MEDIUM = 0 , HIGH = 0 , REALTIME = 0 , NUMBER = 1 , IDLE = 0 , LOW = 0 , MEDIUM = 0 , HIGH = 0 , REALTIME = 0 , NUMBER = 1 , IDLE , LOW , MEDIUM , HIGH , REALTIME , NUMBER } |
线程优先级枚举 Enumeration for thread priorities More... | |
enum class | Priority : uint8_t { IDLE = 0 , LOW = LIBXR_PRIORITY_STEP * 1 , MEDIUM = LIBXR_PRIORITY_STEP * 2 , HIGH = LIBXR_PRIORITY_STEP * 3 , REALTIME = LIBXR_PRIORITY_STEP * 4 , NUMBER = 5 , IDLE , LOW , MEDIUM , HIGH , REALTIME , NUMBER , IDLE = 0 , LOW = 0 , MEDIUM = 0 , HIGH = 0 , REALTIME = 0 , NUMBER = 1 , IDLE = 0 , LOW = 0 , MEDIUM = 0 , HIGH = 0 , REALTIME = 0 , NUMBER = 1 , IDLE , LOW , MEDIUM , HIGH , REALTIME , NUMBER } |
线程优先级枚举 Enumeration for thread priorities More... | |
enum class | Priority { IDLE = 0 , LOW = LIBXR_PRIORITY_STEP * 1 , MEDIUM = LIBXR_PRIORITY_STEP * 2 , HIGH = LIBXR_PRIORITY_STEP * 3 , REALTIME = LIBXR_PRIORITY_STEP * 4 , NUMBER = 5 , IDLE , LOW , MEDIUM , HIGH , REALTIME , NUMBER , IDLE = 0 , LOW = 0 , MEDIUM = 0 , HIGH = 0 , REALTIME = 0 , NUMBER = 1 , IDLE = 0 , LOW = 0 , MEDIUM = 0 , HIGH = 0 , REALTIME = 0 , NUMBER = 1 , IDLE , LOW , MEDIUM , HIGH , REALTIME , NUMBER } |
线程优先级枚举 Enumeration for thread priorities More... | |
enum class | Priority { IDLE = 0 , LOW = LIBXR_PRIORITY_STEP * 1 , MEDIUM = LIBXR_PRIORITY_STEP * 2 , HIGH = LIBXR_PRIORITY_STEP * 3 , REALTIME = LIBXR_PRIORITY_STEP * 4 , NUMBER = 5 , IDLE , LOW , MEDIUM , HIGH , REALTIME , NUMBER , IDLE = 0 , LOW = 0 , MEDIUM = 0 , HIGH = 0 , REALTIME = 0 , NUMBER = 1 , IDLE = 0 , LOW = 0 , MEDIUM = 0 , HIGH = 0 , REALTIME = 0 , NUMBER = 1 , IDLE , LOW , MEDIUM , HIGH , REALTIME , NUMBER } |
线程优先级枚举 Enumeration for thread priorities More... | |
enum class | Priority : uint8_t { IDLE = 0 , LOW = LIBXR_PRIORITY_STEP * 1 , MEDIUM = LIBXR_PRIORITY_STEP * 2 , HIGH = LIBXR_PRIORITY_STEP * 3 , REALTIME = LIBXR_PRIORITY_STEP * 4 , NUMBER = 5 , IDLE , LOW , MEDIUM , HIGH , REALTIME , NUMBER , IDLE = 0 , LOW = 0 , MEDIUM = 0 , HIGH = 0 , REALTIME = 0 , NUMBER = 1 , IDLE = 0 , LOW = 0 , MEDIUM = 0 , HIGH = 0 , REALTIME = 0 , NUMBER = 1 , IDLE , LOW , MEDIUM , HIGH , REALTIME , NUMBER } |
线程优先级枚举 Enumeration for thread priorities More... | |
Public Member Functions | |
Thread () | |
默认构造函数,初始化空线程 Default constructor initializing an empty thread | |
Thread (libxr_thread_handle handle) | |
通过 FreeRTOS 线程句柄创建线程对象 Constructor to create a thread object from a FreeRTOS thread handle | |
template<typename ArgType > | |
void | Create (ArgType arg, void(*function)(ArgType arg), const char *name, size_t stack_depth, Thread::Priority priority) |
创建新线程 Creates a new thread | |
operator libxr_thread_handle () | |
线程对象转换为 FreeRTOS 线程句柄 Converts the thread object to a FreeRTOS thread handle | |
Thread () | |
默认构造函数,初始化空线程 Default constructor initializing an empty thread | |
Thread (libxr_thread_handle handle) | |
通过 POSIX 线程句柄创建线程对象 Constructor to create a thread object from a POSIX thread handle | |
template<typename ArgType > | |
void | Create (ArgType arg, void(*function)(ArgType arg), const char *name, size_t stack_depth, Thread::Priority priority) |
创建新线程 Creates a new thread | |
operator libxr_thread_handle () | |
线程对象转换为 POSIX 线程句柄 Converts the thread object to a POSIX thread handle | |
Thread () | |
默认构造函数,初始化空线程对象 Default constructor initializing an empty thread object | |
Thread (libxr_thread_handle handle) | |
通过线程句柄创建线程对象 Constructor to create a thread object from a thread handle | |
template<typename ArgType > | |
void | Create (ArgType arg, void(*function)(ArgType arg), const char *name, size_t stack_depth, Thread::Priority priority) |
创建并执行新线程 Creates and executes a new thread | |
operator libxr_thread_handle () | |
线程对象转换为线程句柄 Converts the thread object to a thread handle | |
Thread () | |
默认构造函数,初始化空线程对象 Default constructor initializing an empty thread object | |
Thread (libxr_thread_handle handle) | |
通过线程句柄创建线程对象 Constructor to create a thread object from a thread handle | |
template<typename ArgType > | |
void | Create (ArgType arg, void(*function)(ArgType arg), const char *name, size_t stack_depth, Thread::Priority priority) |
创建并执行新线程 Creates and executes a new thread | |
operator libxr_thread_handle () | |
线程对象转换为线程句柄 Converts the thread object to a thread handle | |
Thread () | |
默认构造函数,初始化空线程 Default constructor initializing an empty thread | |
Thread (libxr_thread_handle handle) | |
通过 POSIX 线程句柄创建线程对象 Constructor to create a thread object from a POSIX thread handle | |
template<typename ArgType > | |
void | Create (ArgType arg, void(*function)(ArgType arg), const char *name, size_t stack_depth, Thread::Priority priority) |
创建新线程 Creates a new thread | |
operator libxr_thread_handle () | |
线程对象转换为 POSIX 线程句柄 Converts the thread object to a POSIX thread handle | |
Static Public Member Functions | |
static Thread | Current (void) |
获取当前线程对象 Gets the current thread object | |
static uint32_t | GetTime () |
获取当前系统时间(毫秒) Gets the current system time in milliseconds | |
static void | Sleep (uint32_t milliseconds) |
让线程进入休眠状态 Puts the thread to sleep | |
static void | SleepUntil (TimestampMS &last_waskup_time, uint32_t time_to_sleep) |
让线程休眠直到指定时间点 Puts the thread to sleep until a specified time | |
static void | Yield () |
让出 CPU 以执行其他线程 Yields CPU execution to allow other threads to run | |
static Thread | Current (void) |
获取当前线程对象 Gets the current thread object | |
static uint32_t | GetTime () |
获取当前系统时间(毫秒) Gets the current system time in milliseconds | |
static void | Sleep (uint32_t milliseconds) |
让线程进入休眠状态 Puts the thread to sleep | |
static void | SleepUntil (TimestampMS &last_waskup_time, uint32_t time_to_sleep) |
让线程休眠直到指定时间点 Puts the thread to sleep until a specified time | |
static void | Yield () |
让出 CPU 以执行其他线程 Yields CPU execution to allow other threads to run | |
static Thread | Current (void) |
获取当前线程对象 Gets the current thread object | |
static uint32_t | GetTime () |
获取当前系统时间(毫秒) Gets the current system time in milliseconds | |
static void | Sleep (uint32_t milliseconds) |
让线程进入休眠状态 Puts the thread to sleep | |
static void | SleepUntil (TimestampMS &last_waskup_time, uint32_t time_to_sleep) |
让线程休眠直到指定时间点 Puts the thread to sleep until a specified time | |
static void | Yield () |
让出 CPU 以执行其他线程 Yields CPU execution to allow other threads to run | |
static Thread | Current (void) |
获取当前线程对象 Gets the current thread object | |
static uint32_t | GetTime () |
获取当前系统时间(毫秒) Gets the current system time in milliseconds | |
static void | Sleep (uint32_t milliseconds) |
让线程进入休眠状态 Puts the thread to sleep | |
static void | SleepUntil (TimestampMS &last_waskup_time, uint32_t time_to_sleep) |
让线程休眠直到指定时间点 Puts the thread to sleep until a specified time | |
static void | Yield () |
让出 CPU 以执行其他线程 Yields CPU execution to allow other threads to run | |
static Thread | Current (void) |
获取当前线程对象 Gets the current thread object | |
static uint32_t | GetTime () |
获取当前系统时间(毫秒) Gets the current system time in milliseconds | |
static void | Sleep (uint32_t milliseconds) |
让线程进入休眠状态 Puts the thread to sleep | |
static void | SleepUntil (TimestampMS &last_waskup_time, uint32_t time_to_sleep) |
让线程休眠直到指定时间点 Puts the thread to sleep until a specified time | |
static void | Yield () |
让出 CPU 以执行其他线程 Yields CPU execution to allow other threads to run | |
Private Attributes | |
libxr_thread_handle | thread_handle_ |
FreeRTOS 线程句柄 FreeRTOS thread handle. | |
线程管理类,封装 FreeRTOS 任务创建和调度 Thread management class encapsulating FreeRTOS task creation and scheduling
线程管理类,提供线程的创建、调度和时间管理功能 Thread management class that provides thread creation, scheduling, and time management
线程管理类,封装 POSIX 线程创建和调度 Thread management class encapsulating POSIX thread creation and scheduling
Definition at line 14 of file thread.hpp.
|
strong |
线程优先级枚举 Enumeration for thread priorities
Definition at line 21 of file thread.hpp.
|
strong |
线程优先级枚举 Enumeration for thread priorities
Definition at line 20 of file thread.hpp.
|
strong |
线程优先级枚举 Enumeration for thread priorities
Definition at line 22 of file thread.hpp.
|
strong |
线程优先级枚举 Enumeration for thread priorities
Definition at line 22 of file thread.hpp.
|
strong |
线程优先级枚举 Enumeration for thread priorities
Definition at line 21 of file thread.hpp.
|
inline |
默认构造函数,初始化空线程 Default constructor initializing an empty thread
Definition at line 35 of file thread.hpp.
|
inline |
通过 FreeRTOS 线程句柄创建线程对象 Constructor to create a thread object from a FreeRTOS thread handle
handle | FreeRTOS 线程句柄 FreeRTOS thread handle |
Definition at line 42 of file thread.hpp.
|
inline |
默认构造函数,初始化空线程 Default constructor initializing an empty thread
Definition at line 34 of file thread.hpp.
|
inline |
通过 POSIX 线程句柄创建线程对象 Constructor to create a thread object from a POSIX thread handle
handle | POSIX 线程句柄 POSIX thread handle |
Definition at line 41 of file thread.hpp.
|
inline |
默认构造函数,初始化空线程对象 Default constructor initializing an empty thread object
Definition at line 36 of file thread.hpp.
|
inline |
通过线程句柄创建线程对象 Constructor to create a thread object from a thread handle
handle | 线程句柄 Thread handle |
Definition at line 43 of file thread.hpp.
|
inline |
默认构造函数,初始化空线程对象 Default constructor initializing an empty thread object
Definition at line 36 of file thread.hpp.
|
inline |
通过线程句柄创建线程对象 Constructor to create a thread object from a thread handle
handle | 线程句柄 Thread handle |
Definition at line 43 of file thread.hpp.
|
inline |
默认构造函数,初始化空线程 Default constructor initializing an empty thread
Definition at line 35 of file thread.hpp.
|
inline |
通过 POSIX 线程句柄创建线程对象 Constructor to create a thread object from a POSIX thread handle
handle | POSIX 线程句柄 POSIX thread handle |
Definition at line 42 of file thread.hpp.
|
inline |
创建新线程 Creates a new thread
ArgType | 线程函数的参数类型 The type of argument for the thread function |
arg | 线程函数的参数 Argument for the thread function |
function | 线程执行的函数 Function executed by the thread |
name | 线程名称 Thread name |
stack_depth | 线程栈大小(字节) Stack size of the thread (bytes) |
priority | 线程优先级 Thread priority |
该方法基于 FreeRTOS xTaskCreate()
创建新线程,执行 function
并传递 arg
作为参数。 线程优先级 priority
必须符合 FreeRTOS 配置的 configMAX_PRIORITIES
约束。
This method creates a new thread using FreeRTOS xTaskCreate()
, executing function
with arg
as the argument. The thread priority priority
must adhere to FreeRTOS configuration constraints defined by configMAX_PRIORITIES
.
Definition at line 64 of file thread.hpp.
|
inline |
创建新线程 Creates a new thread
ArgType | 线程函数的参数类型 The type of argument for the thread function |
arg | 线程函数的参数 Argument for the thread function |
function | 线程执行的函数 Function executed by the thread |
name | 线程名称 Thread name |
stack_depth | 线程栈大小(字节) Stack size of the thread (bytes) |
priority | 线程优先级 Thread priority |
该方法基于 POSIX pthread_create()
创建新线程,执行 function
并传递 arg
作为参数。 线程栈大小 stack_depth
需要进行调整以符合 POSIX 线程的栈管理方式。 如果系统支持 SCHED_RR
调度策略,则设置线程优先级。
This method creates a new thread using POSIX pthread_create()
, executing function
with arg
as the argument. The stack_depth
needs adjustment for POSIX thread stack management. If the system supports SCHED_RR
scheduling, thread priority is set accordingly.
线程数据封装类 Thread data encapsulation class
构造函数,存储线程相关数据 Constructor to store thread-related data
线程入口函数,执行用户定义的线程函数 Thread entry function that executes the user-defined function
arg | 线程参数 Thread argument |
nullptr
The return value is always nullptr
< 线程执行的函数 Function executed by the thread
< 线程函数的参数 Argument passed to the thread function
< 线程名称 Thread name
Definition at line 64 of file thread.hpp.
|
inline |
创建并执行新线程 Creates and executes a new thread
ArgType | 线程函数的参数类型 The type of argument for the thread function |
arg | 线程函数的参数 Argument for the thread function |
function | 线程执行的函数 Function executed by the thread |
name | 线程名称(未使用) Thread name (unused) |
stack_depth | 线程栈大小(未使用) Stack size of the thread (unused) |
priority | 线程优先级(未使用) Thread priority (unused) |
此函数是一个简化版本的线程创建,仅执行 function(arg)
,并且只允许创建一次。 由于 name
、stack_depth
和 priority
未实际使用,主要用于测试或占位用途。
This function is a simplified version of thread creation, executing only function(arg)
, and it ensures that the thread is created only once. The parameters name
, stack_depth
, and priority
are unused and mainly serve as placeholders or for testing purposes.
Definition at line 65 of file thread.hpp.
|
inline |
创建并执行新线程 Creates and executes a new thread
ArgType | 线程函数的参数类型 The type of argument for the thread function |
arg | 线程函数的参数 Argument for the thread function |
function | 线程执行的函数 Function executed by the thread |
name | 线程名称(未使用) Thread name (unused) |
stack_depth | 线程栈大小(未使用) Stack size of the thread (unused) |
priority | 线程优先级(未使用) Thread priority (unused) |
此函数是一个简化版本的线程创建,仅执行 function(arg)
,并且只允许创建一次。 由于 name
、stack_depth
和 priority
未实际使用,主要用于测试或占位用途。
This function is a simplified version of thread creation, executing only function(arg)
, and it ensures that the thread is created only once. The parameters name
, stack_depth
, and priority
are unused and mainly serve as placeholders or for testing purposes.
Definition at line 65 of file thread.hpp.
|
inline |
创建新线程 Creates a new thread
ArgType | 线程函数的参数类型 The type of argument for the thread function |
arg | 线程函数的参数 Argument for the thread function |
function | 线程执行的函数 Function executed by the thread |
name | 线程名称 Thread name |
stack_depth | 线程栈大小(字节) Stack size of the thread (bytes) |
priority | 线程优先级 Thread priority |
该方法基于 POSIX pthread_create()
创建新线程,执行 function
并传递 arg
作为参数。 线程栈大小 stack_depth
需要进行调整以符合 POSIX 线程的栈管理方式。 如果系统支持 SCHED_RR
调度策略,则设置线程优先级。
This method creates a new thread using POSIX pthread_create()
, executing function
with arg
as the argument. The stack_depth
needs adjustment for POSIX thread stack management. If the system supports SCHED_RR
scheduling, thread priority is set accordingly.
线程数据封装类 Thread data encapsulation class
构造函数,存储线程相关数据 Constructor to store thread-related data
线程入口函数,执行用户定义的线程函数 Thread entry function that executes the user-defined function
arg | 线程参数 Thread argument |
nullptr
The return value is always nullptr
< 线程执行的函数 Function executed by the thread
< 线程函数的参数 Argument passed to the thread function
< 线程名称 Thread name
Definition at line 65 of file thread.hpp.
获取当前线程对象 Gets the current thread object
Definition at line 7 of file thread.cpp.
获取当前线程对象 Gets the current thread object
获取当前线程对象 Gets the current thread object
获取当前线程对象 Gets the current thread object
获取当前线程对象 Gets the current thread object
|
static |
获取当前系统时间(毫秒) Gets the current system time in milliseconds
Definition at line 16 of file thread.cpp.
获取当前系统时间(毫秒) Gets the current system time in milliseconds
获取当前系统时间(毫秒) Gets the current system time in milliseconds
获取当前系统时间(毫秒) Gets the current system time in milliseconds
获取当前系统时间(毫秒) Gets the current system time in milliseconds
|
inline |
线程对象转换为 FreeRTOS 线程句柄 Converts the thread object to a FreeRTOS thread handle
Definition at line 133 of file thread.hpp.
|
inline |
线程对象转换为 POSIX 线程句柄 Converts the thread object to a POSIX thread handle
Definition at line 215 of file thread.hpp.
|
inline |
线程对象转换为线程句柄 Converts the thread object to a thread handle
Definition at line 120 of file thread.hpp.
|
inline |
线程对象转换为线程句柄 Converts the thread object to a thread handle
Definition at line 120 of file thread.hpp.
|
inline |
线程对象转换为 POSIX 线程句柄 Converts the thread object to a POSIX thread handle
Definition at line 216 of file thread.hpp.
让线程进入休眠状态 Puts the thread to sleep
milliseconds | 休眠时间(毫秒) Sleep duration in milliseconds |
Definition at line 9 of file thread.cpp.
让线程进入休眠状态 Puts the thread to sleep
milliseconds | 休眠时间(毫秒) Sleep duration in milliseconds |
让线程进入休眠状态 Puts the thread to sleep
milliseconds | 休眠时间(毫秒) Sleep duration in milliseconds |
让线程进入休眠状态 Puts the thread to sleep
milliseconds | 休眠时间(毫秒) Sleep duration in milliseconds |
让线程进入休眠状态 Puts the thread to sleep
milliseconds | 休眠时间(毫秒) Sleep duration in milliseconds |
|
static |
让线程休眠直到指定时间点 Puts the thread to sleep until a specified time
last_waskup_time | 上次唤醒时间 Last wake-up time |
time_to_sleep | 休眠时长(毫秒) Sleep duration in milliseconds |
Definition at line 11 of file thread.cpp.
|
static |
让线程休眠直到指定时间点 Puts the thread to sleep until a specified time
last_waskup_time | 上次唤醒时间 Last wake-up time |
time_to_sleep | 休眠时长(毫秒) Sleep duration in milliseconds |
|
static |
让线程休眠直到指定时间点 Puts the thread to sleep until a specified time
last_waskup_time | 上次唤醒时间 Last wake-up time |
time_to_sleep | 休眠时长(毫秒) Sleep duration in milliseconds |
|
static |
让线程休眠直到指定时间点 Puts the thread to sleep until a specified time
last_waskup_time | 上次唤醒时间 Last wake-up time |
time_to_sleep | 休眠时长(毫秒) Sleep duration in milliseconds |
|
static |
让线程休眠直到指定时间点 Puts the thread to sleep until a specified time
last_waskup_time | 上次唤醒时间 Last wake-up time |
time_to_sleep | 休眠时长(毫秒) Sleep duration in milliseconds |
|
static |
让出 CPU 以执行其他线程 Yields CPU execution to allow other threads to run
Definition at line 18 of file thread.cpp.
|
private |
FreeRTOS 线程句柄 FreeRTOS thread handle.
线程句柄 Thread handle
POSIX 线程句柄 POSIX thread handle.
Definition at line 136 of file thread.hpp.