XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
DThd.hxx
浏览该文件的文档.
1
13#ifndef __xwos_cxx_DThd_hxx__
14#define __xwos_cxx_DThd_hxx__
15
16#include <xwos/osal/thd.hxx>
17
18namespace xwos {
19
37class DThd
38{
39 private:
43 public:
53 DThd(const char * name, xwsz_t stack_size,
54 xwsz_t stack_guard_size = XWOS_STACK_GUARD_SIZE_DEFAULT,
55 xwpr_t priority = XWOS_SKD_PRIORITY_RT_MIN, bool detached = false,
56 bool privileged = true);
58 xwer_t getCtorRc() { return mCtorRc; }
65 {
66 return xwos_thd_get_stack_info(mThdDesc, stack);
67 }
80 {
81 return xwos_thd_join(mThdDesc, trc);
82 }
87 {
88 return xwos_thd_stop(mThdDesc, trc);
89 }
97 struct xwos_thd * getXwosObj() { return mThdDesc.thd; }
98
99 /* 生命周期管理 */
103 protected:
104 /* 线程主函数 */
109
110 /* 只能在当前线程函数中调用的API */
114 void yield()
115 {
117 }
122 void exit(xwer_t rc)
123 {
124 xwos_cthd_exit(rc);
125 }
130 {
131 return xwos_cthd_shld_frz();
132 }
137 {
138 return xwos_cthd_shld_stop();
139 }
145 {
146 return xwos_cthd_sleep(dur);
147 }
153 {
154 return xwos_cthd_sleep_to(to);
155 }
164 {
165 return xwos_cthd_sleep_from(from, dur);
166 }
171 {
172 return xwos_cthd_freeze();
173 }
174
175 private:
177};
178
183} // namespace xwos
184
185#endif /* xwos/cxx/DThd.hxx */
动态线程
Definition DThd.hxx:38
xwer_t mCtorRc
Definition DThd.hxx:41
static xwer_t sThdMainFunction(DThd *thd)
xwer_t intr()
中断线程的阻塞态和睡眠态
Definition DThd.hxx:71
xwer_t sleepTo(xwtm_t to)
当前线程睡眠到一个时间点
Definition DThd.hxx:152
xwer_t freeze(void)
冻结当前线程
Definition DThd.hxx:170
xwer_t detach()
终止线程并等待它退出
Definition DThd.hxx:93
xwer_t quit()
通知线程退出
Definition DThd.hxx:75
xwos_thd_d mThdDesc
Definition DThd.hxx:40
xwer_t stop(xwer_t *trc)
通知线程退出,等待线程结束并获取它的返回值
Definition DThd.hxx:86
xwer_t acquire()
Definition DThd.hxx:100
xwer_t sleepFrom(xwtm_t *from, xwtm_t dur)
当前线程从一个时间起点睡眠到另一个时间点
Definition DThd.hxx:163
xwer_t join(xwer_t *trc)
等待线程结束并获取它的返回值
Definition DThd.hxx:79
struct xwos_thd * getXwosObj()
获取XWOS对象指针
Definition DThd.hxx:97
xwer_t getCtorRc()
Definition DThd.hxx:58
bool shouldFreeze()
判断当前线程是否可被冻结
Definition DThd.hxx:129
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)
动态线程构造函数
xwer_t getStackInfo(struct xwos_thd_stack_info *stack)
获取当前线程的栈信息
Definition DThd.hxx:64
bool shouldStop()
判断当前线程是否可以退出
Definition DThd.hxx:136
void yield()
当前线程通知调度器重新调度
Definition DThd.hxx:114
void exit(xwer_t rc)
退出当前线程
Definition DThd.hxx:122
xwer_t release()
Definition DThd.hxx:101
virtual xwer_t thdMainFunction()
线程主函数,用户需要重新实现此函数
xwer_t sleep(xwtm_t dur)
当前线程睡眠一段时间
Definition DThd.hxx:144
xws64_t xwtm_t
XWOS系统时间 (有符号)
Definition type.h:742
signed long xwer_t
Definition type.h:554
xws32_t xwpr_t
Definition type.h:534
unsigned long xwsz_t
Definition type.h:339
#define XWOS_SKD_PRIORITY_RT_MIN
XWOS API:最小实时优先级
Definition skd.h:89
static xwer_t xwos_cthd_sleep_to(xwtm_t to)
XWOS API:线程睡眠到一个时间点
Definition thd.h:777
static xwer_t xwos_thd_release(xwos_thd_d thdd)
XWOS API:检查对象的标签并减少引用计数
Definition thd.h:387
static xwer_t xwos_thd_stop(xwos_thd_d thdd, xwer_t *trc)
XWOS API:终止线程并等待它退出,回收线程内存资源,并抛出线程的返回值
Definition thd.h:543
static bool xwos_cthd_shld_stop(void)
XWOS API:判断当前线程是否可以退出
Definition thd.h:694
static xwer_t xwos_thd_intr(xwos_thd_d thdd)
XWOS API:中断线程的阻塞态和睡眠态
Definition thd.h:454
static xwer_t xwos_cthd_sleep_from(xwtm_t *from, xwtm_t dur)
XWOS API:线程从一个时间起点睡眠到另一个时间点
Definition thd.h:806
static xwer_t xwos_thd_acquire(xwos_thd_d thdd)
XWOS API:检查线程对象的标签并增加引用计数
Definition thd.h:371
#define XWOS_STACK_GUARD_SIZE_DEFAULT
XWOS API:默认的栈警戒线
Definition thd.h:209
static xwer_t xwos_cthd_freeze(void)
XWOS API:冻结当前线程
Definition thd.h:832
static xwer_t xwos_thd_get_stack_info(xwos_thd_d thdd, struct xwos_thd_stack_info *stack)
XWOS API:获取线程的栈信息
Definition thd.h:422
static bool xwos_cthd_shld_frz(void)
XWOS API:判断当前线程是否可被冻结
Definition thd.h:668
static xwer_t xwos_thd_detach(xwos_thd_d thdd)
XWMP API:分离线程
Definition thd.h:565
static xwer_t xwos_thd_quit(xwos_thd_d thdd)
XWOS API:通知线程退出
Definition thd.h:485
static void xwos_cthd_yield(void)
XWOS API:当前线程通知调度器重新调度
Definition thd.h:639
static void xwos_cthd_exit(xwer_t rc)
XWOS API:退出当前线程
Definition thd.h:654
static xwer_t xwos_cthd_sleep(xwtm_t dur)
XWOS API:当前线程睡眠一段时间
Definition thd.h:754
static xwer_t xwos_thd_join(xwos_thd_d thdd, xwer_t *trc)
XWOS API:等待线程结束,回收线程内存资源,抛出它的返回值
Definition thd.h:520
Definition Bmp.hxx:21
XWOS API:线程对象描述符
Definition thd.h:156
struct xwos_thd * thd
Definition thd.h:157
XWOS API:线程栈信息
Definition thd.h:187
XWOS API:线程对象
Definition thd.h:144
C++操作系统抽象层:线程