XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
xwos::DThd类 参考

动态线程 更多...

#include <DThd.hxx>

xwos::DThd 的协作图:

Public 成员函数

 DThd (const char *name, xwsz_t stack_size, xwsz_t stack_guard_size=XWOS_STACK_GUARD_SIZE_DEFAULT, xwpr_t priority=XWOS_SKD_PRIORITY_RT_MIN, bool detached=false, bool privileged=true)
 动态线程构造函数
 
 ~DThd ()
 
xwer_t getCtorRc ()
 
xwer_t getStackInfo (struct xwos_thd_stack_info *stack)
 获取当前线程的栈信息
 
xwer_t intr ()
 中断线程的阻塞态和睡眠态
 
xwer_t quit ()
 通知线程退出
 
xwer_t join (xwer_t *trc)
 等待线程结束并获取它的返回值
 
xwer_t stop (xwer_t *trc)
 通知线程退出,等待线程结束并获取它的返回值
 
xwer_t detach ()
 终止线程并等待它退出
 
struct xwos_thdgetXwosObj ()
 获取XWOS对象指针
 
xwer_t acquire ()
 
xwer_t release ()
 

Protected 成员函数

virtual xwer_t thdMainFunction ()
 线程主函数,用户需要重新实现此函数
 
void yield ()
 当前线程通知调度器重新调度
 
void exit (xwer_t rc)
 退出当前线程
 
bool shouldFreeze ()
 判断当前线程是否可被冻结
 
bool shouldStop ()
 判断当前线程是否可以退出
 
xwer_t sleep (xwtm_t dur)
 当前线程睡眠一段时间
 
xwer_t sleepTo (xwtm_t to)
 当前线程睡眠到一个时间点
 
xwer_t sleepFrom (xwtm_t *from, xwtm_t dur)
 当前线程从一个时间起点睡眠到另一个时间点
 
xwer_t freeze (void)
 冻结当前线程
 

静态 Private 成员函数

static xwer_t sThdMainFunction (DThd *thd)
 

Private 属性

xwos_thd_d mThdDesc
 
xwer_t mCtorRc
 

详细描述

动态线程

在文件 DThd.hxx37 行定义.

构造及析构函数说明

◆ DThd()

xwos::DThd::DThd ( const char *  name,
xwsz_t  stack_size,
xwsz_t  stack_guard_size = XWOS_STACK_GUARD_SIZE_DEFAULT,
xwpr_t  priority = XWOS_SKD_PRIORITY_RT_MIN,
bool  detached = false,
bool  privileged = true 
)

动态线程构造函数

参数
[in]name线程名
[in]stack_size线程栈的大小
[in]stack_guard_size栈内存警戒线位置
[in]priority优先级
[in]detached是否为分离态
[in]privileged是否为特权线程

◆ ~DThd()

xwos::DThd::~DThd ( )

动态线程析构函数

成员函数说明

◆ getCtorRc()

xwer_t xwos::DThd::getCtorRc ( )
inline

获取动态线程构造的结果

在文件 DThd.hxx58 行定义.

◆ getStackInfo()

xwer_t xwos::DThd::getStackInfo ( struct xwos_thd_stack_info stack)
inline

获取当前线程的栈信息

参数
[out]stack用于返回线程栈信息的缓冲区

在文件 DThd.hxx64 行定义.

65 {
66 return xwos_thd_get_stack_info(mThdDesc, stack);
67 }
xwos_thd_d mThdDesc
Definition DThd.hxx:40
static xwer_t xwos_thd_get_stack_info(xwos_thd_d thdd, struct xwos_thd_stack_info *stack)
XWOS API:获取线程的栈信息
Definition thd.h:422
函数调用图:

◆ intr()

xwer_t xwos::DThd::intr ( )
inline

中断线程的阻塞态和睡眠态

在文件 DThd.hxx71 行定义.

71{ return xwos_thd_intr(mThdDesc); }
static xwer_t xwos_thd_intr(xwos_thd_d thdd)
XWOS API:中断线程的阻塞态和睡眠态
Definition thd.h:454
函数调用图:

◆ quit()

xwer_t xwos::DThd::quit ( )
inline

通知线程退出

在文件 DThd.hxx75 行定义.

75{ return xwos_thd_quit(mThdDesc); }
static xwer_t xwos_thd_quit(xwos_thd_d thdd)
XWOS API:通知线程退出
Definition thd.h:485
函数调用图:

◆ join()

xwer_t xwos::DThd::join ( xwer_t trc)
inline

等待线程结束并获取它的返回值

在文件 DThd.hxx79 行定义.

80 {
81 return xwos_thd_join(mThdDesc, trc);
82 }
static xwer_t xwos_thd_join(xwos_thd_d thdd, xwer_t *trc)
XWOS API:等待线程结束,回收线程内存资源,抛出它的返回值
Definition thd.h:520
函数调用图:

◆ stop()

xwer_t xwos::DThd::stop ( xwer_t trc)
inline

通知线程退出,等待线程结束并获取它的返回值

在文件 DThd.hxx86 行定义.

87 {
88 return xwos_thd_stop(mThdDesc, trc);
89 }
static xwer_t xwos_thd_stop(xwos_thd_d thdd, xwer_t *trc)
XWOS API:终止线程并等待它退出,回收线程内存资源,并抛出线程的返回值
Definition thd.h:543
函数调用图:

◆ detach()

xwer_t xwos::DThd::detach ( )
inline

终止线程并等待它退出

在文件 DThd.hxx93 行定义.

93{ return xwos_thd_detach(mThdDesc); }
static xwer_t xwos_thd_detach(xwos_thd_d thdd)
XWMP API:分离线程
Definition thd.h:565
函数调用图:

◆ getXwosObj()

struct xwos_thd * xwos::DThd::getXwosObj ( )
inline

获取XWOS对象指针

在文件 DThd.hxx97 行定义.

97{ return mThdDesc.thd; }
struct xwos_thd * thd
Definition thd.h:157

◆ acquire()

xwer_t xwos::DThd::acquire ( )
inline

增加引用计数

在文件 DThd.hxx100 行定义.

函数调用图:

◆ release()

xwer_t xwos::DThd::release ( )
inline

减少引用计数

在文件 DThd.hxx101 行定义.

函数调用图:

◆ thdMainFunction()

virtual xwer_t xwos::DThd::thdMainFunction ( )
protectedvirtual

线程主函数,用户需要重新实现此函数

◆ yield()

void xwos::DThd::yield ( )
inlineprotected

当前线程通知调度器重新调度

在文件 DThd.hxx114 行定义.

115 {
117 }
static void xwos_cthd_yield(void)
XWOS API:当前线程通知调度器重新调度
Definition thd.h:639
函数调用图:

◆ exit()

void xwos::DThd::exit ( xwer_t  rc)
inlineprotected

退出当前线程

参数
[in]rc线程退出时抛出的返回值

在文件 DThd.hxx122 行定义.

123 {
124 xwos_cthd_exit(rc);
125 }
static void xwos_cthd_exit(xwer_t rc)
XWOS API:退出当前线程
Definition thd.h:654
函数调用图:

◆ shouldFreeze()

bool xwos::DThd::shouldFreeze ( )
inlineprotected

判断当前线程是否可被冻结

在文件 DThd.hxx129 行定义.

130 {
131 return xwos_cthd_shld_frz();
132 }
static bool xwos_cthd_shld_frz(void)
XWOS API:判断当前线程是否可被冻结
Definition thd.h:668
函数调用图:

◆ shouldStop()

bool xwos::DThd::shouldStop ( )
inlineprotected

判断当前线程是否可以退出

在文件 DThd.hxx136 行定义.

137 {
138 return xwos_cthd_shld_stop();
139 }
static bool xwos_cthd_shld_stop(void)
XWOS API:判断当前线程是否可以退出
Definition thd.h:694
函数调用图:

◆ sleep()

xwer_t xwos::DThd::sleep ( xwtm_t  dur)
inlineprotected

当前线程睡眠一段时间

参数
[in]dur期望睡眠的时间

在文件 DThd.hxx144 行定义.

145 {
146 return xwos_cthd_sleep(dur);
147 }
static xwer_t xwos_cthd_sleep(xwtm_t dur)
XWOS API:当前线程睡眠一段时间
Definition thd.h:754
函数调用图:

◆ sleepTo()

xwer_t xwos::DThd::sleepTo ( xwtm_t  to)
inlineprotected

当前线程睡眠到一个时间点

参数
[in]to期望唤醒的时间点

在文件 DThd.hxx152 行定义.

153 {
154 return xwos_cthd_sleep_to(to);
155 }
static xwer_t xwos_cthd_sleep_to(xwtm_t to)
XWOS API:线程睡眠到一个时间点
Definition thd.h:777
函数调用图:

◆ sleepFrom()

xwer_t xwos::DThd::sleepFrom ( xwtm_t from,
xwtm_t  dur 
)
inlineprotected

当前线程从一个时间起点睡眠到另一个时间点

参数
[in,out]from指向缓冲区的指针,此缓冲区:
  • (I) 输入时,作为时间起点
  • (O) 输出时,返回线程被唤醒的时间(可作为下一次时间起点)
[in]dur期望被唤醒的时间增量(相对于时间原点)

在文件 DThd.hxx163 行定义.

164 {
165 return xwos_cthd_sleep_from(from, dur);
166 }
static xwer_t xwos_cthd_sleep_from(xwtm_t *from, xwtm_t dur)
XWOS API:线程从一个时间起点睡眠到另一个时间点
Definition thd.h:806
函数调用图:

◆ freeze()

xwer_t xwos::DThd::freeze ( void  )
inlineprotected

冻结当前线程

在文件 DThd.hxx170 行定义.

171 {
172 return xwos_cthd_freeze();
173 }
static xwer_t xwos_cthd_freeze(void)
XWOS API:冻结当前线程
Definition thd.h:832
函数调用图:

◆ sThdMainFunction()

static xwer_t xwos::DThd::sThdMainFunction ( DThd thd)
staticprivate

结构体成员变量说明

◆ mThdDesc

xwos_thd_d xwos::DThd::mThdDesc
private

线程描述符

在文件 DThd.hxx40 行定义.

◆ mCtorRc

xwer_t xwos::DThd::mCtorRc
private

线程构造的结果

在文件 DThd.hxx41 行定义.


该类的文档由以下文件生成: