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

静态线程 更多...

#include <SThd.hxx>

xwos::SThd 的协作图:

Public 成员函数

 SThd (const char *name, xwstk_t *stack, 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)
 静态线程构造函数
 
 ~SThd ()
 
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 grab ()
 
xwer_t put ()
 

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 成员函数

void operator delete (void *obj)=delete
 

静态 Private 成员函数

static xwer_t sThdMainFunction (SThd *thd)
 
static void * operator new (xwsz_t sz)=delete
 

Private 属性

xwos_thd_d mThdDesc
 
struct xwos_thd mThd
 
xwer_t mCtorRc
 

详细描述

静态线程

在文件 SThd.hxx37 行定义.

构造及析构函数说明

◆ SThd()

xwos::SThd::SThd ( const char *  name,
xwstk_t stack,
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线程栈内存
[in]stack_size线程栈的大小
[in]stack_guard_size栈内存警戒线位置
[in]priority优先级
[in]detached是否为分离态
[in]privileged是否为特权线程

◆ ~SThd()

xwos::SThd::~SThd ( )

静态线程析构函数

成员函数说明

◆ getCtorRc()

xwer_t xwos::SThd::getCtorRc ( )
inline

获取静态线程构造的结果

在文件 SThd.hxx60 行定义.

◆ getStackInfo()

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

获取当前线程的栈信息

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

在文件 SThd.hxx66 行定义.

67 {
68 return xwos_thd_get_stack_info(mThdDesc, stack);
69 }
xwos_thd_d mThdDesc
Definition SThd.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::SThd::intr ( )
inline

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

在文件 SThd.hxx73 行定义.

73{ 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::SThd::quit ( )
inline

通知线程退出

在文件 SThd.hxx77 行定义.

77{ 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::SThd::join ( xwer_t trc)
inline

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

在文件 SThd.hxx81 行定义.

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

◆ stop()

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

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

在文件 SThd.hxx88 行定义.

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

◆ detach()

xwer_t xwos::SThd::detach ( )
inline

终止线程并等待它退出

在文件 SThd.hxx95 行定义.

95{ 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::SThd::getXwosObj ( )
inline

获取XWOS对象指针

在文件 SThd.hxx99 行定义.

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

◆ grab()

xwer_t xwos::SThd::grab ( )
inline

增加引用计数

在文件 SThd.hxx102 行定义.

函数调用图:

◆ put()

xwer_t xwos::SThd::put ( )
inline

减少引用计数

在文件 SThd.hxx103 行定义.

函数调用图:

◆ thdMainFunction()

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

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

◆ yield()

void xwos::SThd::yield ( )
inlineprotected

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

在文件 SThd.hxx116 行定义.

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

◆ exit()

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

退出当前线程

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

在文件 SThd.hxx124 行定义.

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

◆ shouldFreeze()

bool xwos::SThd::shouldFreeze ( )
inlineprotected

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

在文件 SThd.hxx131 行定义.

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

◆ shouldStop()

bool xwos::SThd::shouldStop ( )
inlineprotected

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

在文件 SThd.hxx138 行定义.

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

◆ sleep()

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

当前线程睡眠一段时间

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

在文件 SThd.hxx146 行定义.

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

◆ sleepTo()

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

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

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

在文件 SThd.hxx154 行定义.

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

◆ sleepFrom()

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

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

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

在文件 SThd.hxx165 行定义.

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

◆ freeze()

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

冻结当前线程

在文件 SThd.hxx172 行定义.

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

◆ sThdMainFunction()

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

◆ operator new()

static void * xwos::SThd::operator new ( xwsz_t  sz)
staticprivatedelete

◆ operator delete()

void xwos::SThd::operator delete ( void *  obj)
privatedelete

结构体成员变量说明

◆ mThdDesc

xwos_thd_d xwos::SThd::mThdDesc
private

线程描述符

在文件 SThd.hxx40 行定义.

◆ mThd

struct xwos_thd xwos::SThd::mThd
private

线程结构体

在文件 SThd.hxx41 行定义.

◆ mCtorRc

xwer_t xwos::SThd::mCtorRc
private

线程构造的结果

在文件 SThd.hxx42 行定义.


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