XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
SThd.hxx
浏览该文件的文档.
1
13#ifndef __xwos_cxx_SThd_hxx__
14#define __xwos_cxx_SThd_hxx__
15
16#include <xwos/osal/thd.hxx>
17
18namespace xwos {
19
37class SThd
38{
39 private:
41 struct xwos_thd mThd;
44 public:
55 SThd(const char * name, xwstk_t * stack, xwsz_t stack_size,
56 xwsz_t stack_guard_size = XWOS_STACK_GUARD_SIZE_DEFAULT,
57 xwpr_t priority = XWOS_SKD_PRIORITY_RT_MIN, bool detached = false,
58 bool privileged = true);
60 xwer_t getCtorRc() { return mCtorRc; }
67 {
68 return xwos_thd_get_stack_info(mThdDesc, stack);
69 }
82 {
83 return xwos_thd_join(mThdDesc, trc);
84 }
89 {
90 return xwos_thd_stop(mThdDesc, trc);
91 }
99 struct xwos_thd * getXwosObj() { return mThdDesc.thd; }
100
101 /* 生命周期管理 */
105 protected:
106 /* 线程主函数 */
111
112 /* 只能在当前线程函数中调用的API */
116 void yield()
117 {
119 }
124 void exit(xwer_t rc)
125 {
126 xwos_cthd_exit(rc);
127 }
132 {
133 return xwos_cthd_shld_frz();
134 }
139 {
140 return xwos_cthd_shld_stop();
141 }
147 {
148 return xwos_cthd_sleep(dur);
149 }
155 {
156 return xwos_cthd_sleep_to(to);
157 }
166 {
167 return xwos_cthd_sleep_from(from, dur);
168 }
173 {
174 return xwos_cthd_freeze();
175 }
176
177 private:
179 static void * operator new(xwsz_t sz) = delete;
180 void operator delete(void * obj) = delete;
181};
182
187} // namespace xwos
188
189#endif /* xwos/cxx/SThd.hxx */
静态线程
Definition SThd.hxx:38
xwer_t quit()
通知线程退出
Definition SThd.hxx:77
xwer_t mCtorRc
Definition SThd.hxx:42
xwos_thd_d mThdDesc
Definition SThd.hxx:40
struct xwos_thd * getXwosObj()
获取XWOS对象指针
Definition SThd.hxx:99
static xwer_t sThdMainFunction(SThd *thd)
xwer_t grab()
Definition SThd.hxx:102
xwer_t join(xwer_t *trc)
等待线程结束并获取它的返回值
Definition SThd.hxx:81
xwer_t stop(xwer_t *trc)
通知线程退出,等待线程结束并获取它的返回值
Definition SThd.hxx:88
xwer_t put()
Definition SThd.hxx:103
bool shouldFreeze()
判断当前线程是否可被冻结
Definition SThd.hxx:131
xwer_t intr()
中断线程的阻塞态和睡眠态
Definition SThd.hxx:73
xwer_t getCtorRc()
Definition SThd.hxx:60
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)
静态线程构造函数
void yield()
当前线程通知调度器重新调度
Definition SThd.hxx:116
virtual xwer_t thdMainFunction()
线程主函数,用户需要重新实现此函数
xwer_t freeze(void)
冻结当前线程
Definition SThd.hxx:172
bool shouldStop()
判断当前线程是否可以退出
Definition SThd.hxx:138
xwer_t getStackInfo(struct xwos_thd_stack_info *stack)
获取当前线程的栈信息
Definition SThd.hxx:66
xwer_t detach()
终止线程并等待它退出
Definition SThd.hxx:95
struct xwos_thd mThd
Definition SThd.hxx:41
void exit(xwer_t rc)
退出当前线程
Definition SThd.hxx:124
xwer_t sleep(xwtm_t dur)
当前线程睡眠一段时间
Definition SThd.hxx:146
xwer_t sleepTo(xwtm_t to)
当前线程睡眠到一个时间点
Definition SThd.hxx:154
xwer_t sleepFrom(xwtm_t *from, xwtm_t dur)
当前线程从一个时间起点睡眠到另一个时间点
Definition SThd.hxx:165
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
xwptr_t xwstk_t
Definition type.h:392
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_grab(xwos_thd_d thdd)
XWOS API:增加线程对象的引用计数
Definition thd.h:306
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_thd_put(xwos_thd_d thdd)
XWOS API:减少线程对象的引用计数
Definition thd.h:325
static xwer_t xwos_cthd_sleep_from(xwtm_t *from, xwtm_t dur)
XWOS API:线程从一个时间起点睡眠到另一个时间点
Definition thd.h:806
#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++操作系统抽象层:线程