XWOS API  4.0
XWOS C/C++ API参考手册
载入中...
搜索中...
未找到
DMtx.cxx
浏览该文件的文档.
1
14
15namespace xwos {
16namespace lock {
17
18/* DMtx::Grd Non-static Member */
19DMtx::Grd::Grd(DMtx * mtx, enum LockMode mode, xwtm_t to)
20 : mMtx(mtx)
21 , mLockMode(mode)
22{
23 if (nullptr != mMtx) {
24 switch (mode) {
27 break;
30 break;
33 break;
36 break;
38 mRc = XWOK;
39 break;
40 default:
42 mRc = XWOK;
43 break;
44 }
45 }
46}
47
49{
50 if (nullptr != mMtx) {
51 if (DMtx::LockMode::DMtxUnlock != mLockMode) {
52 xwos_mtx_unlock(mMtx->mMtxDesc.mtx);
53 }
54 }
55}
56
58{
59 xwer_t rc;
60 if (nullptr != mMtx) {
61 union xwos_ulock lock;
62 xwsq_t lkst;
63
64 lock.osal.mtx = mMtx->mMtxDesc.mtx;
66 rc = xwos_cond_wait_unintr(cond->getXwosObj(), lock, XWOS_LK_MTX, nullptr, &lkst);
67 } else {
68 rc = xwos_cond_wait(cond->getXwosObj(), lock, XWOS_LK_MTX, nullptr, &lkst);
69 }
70 if (rc < 0) {
71 if (XWOS_LKST_UNLOCKED == lkst) {
73 }
74 }
75 } else {
76 rc = -EFAULT;
77 }
78 return rc;
79}
80
82{
83 xwer_t rc;
84 if (nullptr != mMtx) {
85 union xwos_ulock lock;
86 xwsq_t lkst;
87 lock.osal.mtx = mMtx->mMtxDesc.mtx;
89 rc = xwos_cond_wait_unintr(cond->getXwosObj(), lock, XWOS_LK_MTX, nullptr, &lkst);
90 } else {
91 rc = xwos_cond_wait_to(cond->getXwosObj(), lock, XWOS_LK_MTX, nullptr, to, &lkst);
92 }
93 if (rc < 0) {
94 if (XWOS_LKST_UNLOCKED == lkst) {
96 }
97 }
98 } else {
99 rc = -EFAULT;
100 }
101 return rc;
102}
103
104/* DMtx Non-static Member */
106{
108}
109
111{
113}
114
115} // namespace xwos
116} // namespace lock
xwos::lock::DMtx
xwer_t wait(sync::Cond *cond)
等待条件量
Definition DMtx.cxx:57
~Grd()
析构动态互斥锁的RAII机制守卫并解锁互斥锁
Definition DMtx.cxx:48
enum LockMode mLockMode
Definition DMtx.hxx:97
动态互斥锁
Definition DMtx.hxx:73
xwos_mtx_d mMtxDesc
Definition DMtx.hxx:258
DMtx(xwpr_t pr=XWOS_SKD_PRIORITY_RT_MAX)
构造函数
Definition DMtx.cxx:105
LockMode
动态互斥锁的锁模式
Definition DMtx.hxx:78
@ DMtxLockUninterruptable
Definition DMtx.hxx:83
xwer_t mCtorRc
Definition DMtx.hxx:259
条件量基类
Definition Cond.hxx:31
struct xwos_cond * getXwosObj()
Definition Cond.hxx:45
#define EFAULT
Bad address
Definition errno.h:44
#define XWOK
No error
Definition errno.h:182
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 xwsq_t
Definition type.h:445
@ XWOS_LKST_UNLOCKED
Definition type.h:661
@ XWOS_LK_MTX
Definition type.h:641
static xwer_t xwos_mtx_lock_to(struct xwos_mtx *mtx, xwtm_t to)
XWOS API:限时等待上锁互斥锁
Definition mtx.h:329
static xwer_t xwos_mtx_trylock(struct xwos_mtx *mtx)
XWOS API:尝试上锁互斥锁,不会阻塞调用线程
Definition mtx.h:370
static xwer_t xwos_mtx_create(xwos_mtx_d *mtxd, xwpr_t sprio)
XWOS API:动态方式创建互斥锁
Definition mtx.h:182
static xwer_t xwos_mtx_delete(xwos_mtx_d mtxd)
XWOS API:删除动态方式创建的互斥锁
Definition mtx.h:197
static xwer_t xwos_mtx_unlock(struct xwos_mtx *mtx)
XWOS API:解锁互斥锁
Definition mtx.h:279
static xwer_t xwos_mtx_lock(struct xwos_mtx *mtx)
XWOS API:等待并上锁互斥锁
Definition mtx.h:302
static xwer_t xwos_mtx_lock_unintr(struct xwos_mtx *mtx)
XWOS API:等待并上锁互斥锁,且等待不可被中断
Definition mtx.h:348
static xwer_t xwos_cond_wait_unintr(struct xwos_cond *cond, union xwos_ulock lock, xwsq_t lktype, void *lkdata, xwsq_t *lkst)
XWOS API:不可中断地等待条件量
Definition cond.h:543
static xwer_t xwos_cond_wait(struct xwos_cond *cond, union xwos_ulock lock, xwsq_t lktype, void *lkdata, xwsq_t *lkst)
XWOS API:等待条件量
Definition cond.h:432
static xwer_t xwos_cond_wait_to(struct xwos_cond *cond, union xwos_ulock lock, xwsq_t lktype, void *lkdata, xwtm_t to, xwsq_t *lkst)
XWOS API:限时等待条件量
Definition cond.h:492
Definition Cpu.hxx:19
struct xwos_mtx * mtx
Definition mtx.h:90
所有锁的联合
Definition type.h:680
struct xwmp_mtx * mtx
Definition type.h:682
union xwos_ulock::@8 osal