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,
56 xwstk_t * stack, xwsz_t stack_size,
57 xwsz_t stack_guard_size = XWOS_STACK_GUARD_SIZE_DEFAULT,
58 xwpr_t priority = XWOS_SKD_PRIORITY_RT_MIN, bool detached = false,
59 bool privileged = true);
60 ~SThd();
61 xwer_t getCtorRc() { return mCtorRc; }
64 xwer_t join(xwer_t * trc) { return xwos_thd_join(mThdDesc, trc); }
65 xwer_t stop(xwer_t * trc) { return xwos_thd_stop(mThdDesc, trc); }
67 struct xwos_thd * getXwosObj() { return mThdDesc.thd; }
69 /* 生命周期管理 */
73 protected:
74 virtual xwer_t thdMainFunction();
75 /* 只能在当前线程函数中调用的API */
76 void yield() { xwos_cthd_yield(); }
77 void exit(xwer_t rc) { xwos_cthd_exit(rc); }
78 bool shouldFreeze() { return xwos_cthd_shld_frz(); }
79 bool shouldStop() { return xwos_cthd_shld_stop(); }
80 xwer_t sleep(xwtm_t dur) { return xwos_cthd_sleep(dur); }
82 xwer_t sleepFrom(xwtm_t * from, xwtm_t dur) { return xwos_cthd_sleep_from(from, dur); }
83 xwer_t freeze(void) { return xwos_cthd_shld_stop(); }
85 private:
86 static xwer_t sThdMainFunction(SThd * thd);
87 static void * operator new(xwsz_t sz) = delete;
88 void operator delete(void * obj) = delete;
89};
90
95} // namespace xwos
96
97#endif /* xwos/cxx/SThd.hxx */
静态线程
Definition SThd.hxx:38
xwer_t quit()
Definition SThd.hxx:63
xwer_t mCtorRc
Definition SThd.hxx:42
virtual xwer_t thdMainFunction()
Definition SThd.cxx:39
xwos_thd_d mThdDesc
Definition SThd.hxx:40
struct xwos_thd * getXwosObj()
Definition SThd.hxx:67
xwer_t grab()
Definition SThd.hxx:70
xwer_t join(xwer_t *trc)
Definition SThd.hxx:64
xwer_t stop(xwer_t *trc)
Definition SThd.hxx:65
static xwer_t sThdMainFunction(SThd *thd)
Definition SThd.cxx:45
xwer_t put()
Definition SThd.hxx:71
bool shouldFreeze()
Definition SThd.hxx:78
xwer_t intr()
Definition SThd.hxx:62
xwer_t getCtorRc()
Definition SThd.hxx:61
void yield()
Definition SThd.hxx:76
xwer_t freeze(void)
Definition SThd.hxx:83
bool shouldStop()
Definition SThd.hxx:79
xwer_t detach()
Definition SThd.hxx:66
struct xwos_thd mThd
Definition SThd.hxx:41
void exit(xwer_t rc)
Definition SThd.hxx:77
xwer_t sleep(xwtm_t dur)
Definition SThd.hxx:80
xwer_t sleepTo(xwtm_t to)
Definition SThd.hxx:81
xwer_t sleepFrom(xwtm_t *from, xwtm_t dur)
Definition SThd.hxx:82
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:716
static xwer_t xwos_thd_grab(xwos_thd_d thdd)
XWOS API:增加线程对象的引用计数
Definition thd.h:287
static xwer_t xwos_thd_stop(xwos_thd_d thdd, xwer_t *trc)
XWOS API:终止线程并等待它退出,回收线程内存资源,并抛出线程的返回值
Definition thd.h:495
static bool xwos_cthd_shld_stop(void)
XWOS API:判断当前线程是否可以退出
Definition thd.h:633
static xwer_t xwos_thd_intr(xwos_thd_d thdd)
XWOS API:中断线程的阻塞态和睡眠态
Definition thd.h:406
static xwer_t xwos_thd_put(xwos_thd_d thdd)
XWOS API:减少线程对象的引用计数
Definition thd.h:306
static xwer_t xwos_cthd_sleep_from(xwtm_t *from, xwtm_t dur)
XWOS API:线程从一个时间起点睡眠到另一个时间点
Definition thd.h:745
#define XWOS_STACK_GUARD_SIZE_DEFAULT
XWOS API:默认的栈警戒线
Definition thd.h:190
static bool xwos_cthd_shld_frz(void)
XWOS API:判断当前线程是否可被冻结
Definition thd.h:607
static xwer_t xwos_thd_detach(xwos_thd_d thdd)
XWMP API:分离线程
Definition thd.h:517
static xwer_t xwos_thd_quit(xwos_thd_d thdd)
XWOS API:通知线程退出
Definition thd.h:437
static void xwos_cthd_yield(void)
XWOS API:当前线程通知调度器重新调度
Definition thd.h:578
static void xwos_cthd_exit(xwer_t rc)
XWOS API:退出当前线程
Definition thd.h:593
static xwer_t xwos_cthd_sleep(xwtm_t dur)
XWOS API:线程睡眠一段时间
Definition thd.h:693
static xwer_t xwos_thd_join(xwos_thd_d thdd, xwer_t *trc)
XWOS API:等待线程结束,回收线程内存资源,抛出它的返回值
Definition thd.h:472
Definition Cpu.hxx:19
XWOS API:线程对象描述符
Definition thd.h:149
struct xwos_thd * thd
Definition thd.h:150
XWOS API:线程对象
Definition thd.h:137
C++操作系统抽象层:线程