Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lihongda1002
oceanbase
提交
69f20e8e
O
oceanbase
项目概览
lihongda1002
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
69f20e8e
编写于
11月 02, 2022
作者:
C
chinaxing
提交者:
wangzelin.wzl
11月 02, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[4.1] add [[nodiscard]] on LockGuard
上级
2ef87bf6
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
31 addition
and
31 deletion
+31
-31
deps/oblib/src/lib/lock/ob_bucket_lock.h
deps/oblib/src/lib/lock/ob_bucket_lock.h
+8
-8
deps/oblib/src/lib/lock/ob_drw_lock.h
deps/oblib/src/lib/lock/ob_drw_lock.h
+2
-2
deps/oblib/src/lib/lock/ob_latch.h
deps/oblib/src/lib/lock/ob_latch.h
+3
-3
deps/oblib/src/lib/lock/ob_lock_guard.h
deps/oblib/src/lib/lock/ob_lock_guard.h
+1
-1
deps/oblib/src/lib/lock/ob_rwlock.h
deps/oblib/src/lib/lock/ob_rwlock.h
+3
-3
deps/oblib/src/lib/lock/ob_tc_rwlock.h
deps/oblib/src/lib/lock/ob_tc_rwlock.h
+13
-13
deps/oblib/src/lib/lock/threadmutex.h
deps/oblib/src/lib/lock/threadmutex.h
+1
-1
未找到文件。
deps/oblib/src/lib/lock/ob_bucket_lock.h
浏览文件 @
69f20e8e
...
...
@@ -68,7 +68,7 @@ private:
class
ObBucketRLockGuard
final
{
public:
ObBucketRLockGuard
(
ObBucketLock
&
lock
,
const
uint64_t
bucket_index
)
[[
nodiscard
]]
ObBucketRLockGuard
(
ObBucketLock
&
lock
,
const
uint64_t
bucket_index
)
:
lock_
(
lock
),
index_
(
bucket_index
),
ret_
(
OB_SUCCESS
),
...
...
@@ -109,7 +109,7 @@ private:
class
ObBucketWLockGuard
final
{
public:
ObBucketWLockGuard
(
ObBucketLock
&
lock
,
const
uint64_t
bucket_index
)
[[
nodiscard
]]
ObBucketWLockGuard
(
ObBucketLock
&
lock
,
const
uint64_t
bucket_index
)
:
lock_
(
lock
),
index_
(
bucket_index
),
ret_
(
OB_SUCCESS
),
...
...
@@ -150,7 +150,7 @@ private:
class
ObBucketWLockAllGuard
final
{
public:
ObBucketWLockAllGuard
(
ObBucketLock
&
lock
)
[[
nodiscard
]]
ObBucketWLockAllGuard
(
ObBucketLock
&
lock
)
:
lock_
(
lock
),
ret_
(
OB_SUCCESS
),
lock_start_ts_
(
0
)
...
...
@@ -189,7 +189,7 @@ private:
class
ObBucketTryWLockAllGuard
final
{
public:
ObBucketTryWLockAllGuard
(
ObBucketLock
&
lock
)
[[
nodiscard
]]
ObBucketTryWLockAllGuard
(
ObBucketLock
&
lock
)
:
lock_
(
lock
),
ret_
(
OB_SUCCESS
),
lock_start_ts_
(
0
)
...
...
@@ -234,7 +234,7 @@ private:
class
ObBucketTryRLockAllGuard
final
{
public:
ObBucketTryRLockAllGuard
(
ObBucketLock
&
lock
)
[[
nodiscard
]]
ObBucketTryRLockAllGuard
(
ObBucketLock
&
lock
)
:
lock_
(
lock
),
ret_
(
OB_SUCCESS
),
lock_start_ts_
(
0
)
...
...
@@ -279,7 +279,7 @@ private:
class
ObMultiBucketLockGuard
final
{
public:
ObMultiBucketLockGuard
(
ObBucketLock
&
lock
,
const
bool
is_write_lock
);
[[
nodiscard
]]
ObMultiBucketLockGuard
(
ObBucketLock
&
lock
,
const
bool
is_write_lock
);
~
ObMultiBucketLockGuard
();
int
lock_multi_buckets
(
ObIArray
<
uint64_t
>
&
hash_array
);
private:
...
...
@@ -293,7 +293,7 @@ private:
class
ObBucketHashRLockGuard
final
{
public:
ObBucketHashRLockGuard
(
ObBucketLock
&
lock
,
const
uint64_t
hash_value
)
[[
nodiscard
]]
ObBucketHashRLockGuard
(
ObBucketLock
&
lock
,
const
uint64_t
hash_value
)
:
guard_
(
lock
,
lock
.
get_bucket_idx
(
hash_value
))
{
}
...
...
@@ -307,7 +307,7 @@ private:
class
ObBucketHashWLockGuard
final
{
public:
ObBucketHashWLockGuard
(
ObBucketLock
&
lock
,
const
uint64_t
hash_value
)
[[
nodiscard
]]
ObBucketHashWLockGuard
(
ObBucketLock
&
lock
,
const
uint64_t
hash_value
)
:
guard_
(
lock
,
lock
.
get_bucket_idx
(
hash_value
))
{
}
...
...
deps/oblib/src/lib/lock/ob_drw_lock.h
浏览文件 @
69f20e8e
...
...
@@ -34,7 +34,7 @@ public:
class
RDLockGuard
{
public:
explicit
RDLockGuard
(
DRWLock
&
rwlock
)
:
rwlock_
(
rwlock
),
ret_
(
OB_SUCCESS
)
[[
nodiscard
]]
explicit
RDLockGuard
(
DRWLock
&
rwlock
)
:
rwlock_
(
rwlock
),
ret_
(
OB_SUCCESS
)
{
if
(
OB_UNLIKELY
(
OB_SUCCESS
!=
(
ret_
=
rwlock_
.
rdlock
())))
{
COMMON_LOG
(
WARN
,
"Fail to read lock, "
,
K_
(
ret
));
...
...
@@ -58,7 +58,7 @@ public:
class
WRLockGuard
{
public:
explicit
WRLockGuard
(
DRWLock
&
rwlock
)
:
rwlock_
(
rwlock
),
ret_
(
OB_SUCCESS
)
[[
nodiscard
]]
explicit
WRLockGuard
(
DRWLock
&
rwlock
)
:
rwlock_
(
rwlock
),
ret_
(
OB_SUCCESS
)
{
if
(
OB_UNLIKELY
(
OB_SUCCESS
!=
(
ret_
=
rwlock_
.
wrlock
())))
{
COMMON_LOG
(
WARN
,
"Fail to write lock, "
,
K_
(
ret
));
...
...
deps/oblib/src/lib/lock/ob_latch.h
浏览文件 @
69f20e8e
...
...
@@ -364,7 +364,7 @@ private:
class
ObLatchMutexGuard
{
public:
ObLatchMutexGuard
(
ObLatchMutex
&
lock
,
const
uint32_t
latch_id
)
[[
nodiscard
]]
ObLatchMutexGuard
(
ObLatchMutex
&
lock
,
const
uint32_t
latch_id
)
:
lock_
(
lock
),
ret_
(
OB_SUCCESS
)
{
if
(
OB_UNLIKELY
(
OB_SUCCESS
!=
(
ret_
=
lock_
.
lock
(
latch_id
))))
{
...
...
@@ -390,7 +390,7 @@ private:
class
ObLatchRGuard
{
public:
ObLatchRGuard
(
ObLatch
&
lock
,
const
uint32_t
latch_id
)
[[
nodiscard
]]
ObLatchRGuard
(
ObLatch
&
lock
,
const
uint32_t
latch_id
)
:
lock_
(
lock
),
ret_
(
OB_SUCCESS
)
{
...
...
@@ -418,7 +418,7 @@ private:
class
ObLatchWGuard
{
public:
ObLatchWGuard
(
ObLatch
&
lock
,
const
uint32_t
latch_id
)
[[
nodiscard
]]
ObLatchWGuard
(
ObLatch
&
lock
,
const
uint32_t
latch_id
)
:
lock_
(
lock
),
ret_
(
OB_SUCCESS
)
{
...
...
deps/oblib/src/lib/lock/ob_lock_guard.h
浏览文件 @
69f20e8e
...
...
@@ -25,7 +25,7 @@ template <typename LockT>
class
ObLockGuard
{
public:
explicit
ObLockGuard
(
LockT
&
lock
);
[[
nodiscard
]]
explicit
ObLockGuard
(
LockT
&
lock
);
~
ObLockGuard
();
inline
int
get_ret
()
const
{
return
ret_
;
}
private:
...
...
deps/oblib/src/lib/lock/ob_rwlock.h
浏览文件 @
69f20e8e
...
...
@@ -23,7 +23,7 @@ template <class T>
class
ObLockGuardBase
{
public:
ObLockGuardBase
(
const
T
&
lock
,
bool
block
=
true
)
:
lock_
(
lock
)
[[
nodiscard
]]
ObLockGuardBase
(
const
T
&
lock
,
bool
block
=
true
)
:
lock_
(
lock
)
{
acquired_
=
!
(
block
?
lock_
.
lock
()
:
lock_
.
trylock
());
}
...
...
@@ -87,7 +87,7 @@ private:
class
ObRLockGuard
{
public:
ObRLockGuard
(
const
ObRWLock
&
rwlock
,
bool
block
=
true
)
:
guard_
((
*
rwlock
.
rlock
()),
block
)
{}
[[
nodiscard
]]
ObRLockGuard
(
const
ObRWLock
&
rwlock
,
bool
block
=
true
)
:
guard_
((
*
rwlock
.
rlock
()),
block
)
{}
~
ObRLockGuard
(){}
bool
acquired
()
{
return
guard_
.
acquired
();
}
private:
...
...
@@ -97,7 +97,7 @@ private:
class
ObWLockGuard
{
public:
ObWLockGuard
(
const
ObRWLock
&
rwlock
,
bool
block
=
true
)
:
guard_
((
*
rwlock
.
wlock
()),
block
)
{}
[[
nodiscard
]]
ObWLockGuard
(
const
ObRWLock
&
rwlock
,
bool
block
=
true
)
:
guard_
((
*
rwlock
.
wlock
()),
block
)
{}
~
ObWLockGuard
(){}
bool
acquired
()
{
return
guard_
.
acquired
();
}
private:
...
...
deps/oblib/src/lib/lock/ob_tc_rwlock.h
浏览文件 @
69f20e8e
...
...
@@ -54,13 +54,13 @@ public:
enum
{
WRITE_MASK
=
1
<<
31
};
struct
RLockGuard
{
explicit
RLockGuard
(
TCRWLock
&
lock
)
:
lock_
(
lock
)
{
lock_
.
rdlock
();
}
[[
nodiscard
]]
explicit
RLockGuard
(
TCRWLock
&
lock
)
:
lock_
(
lock
)
{
lock_
.
rdlock
();
}
~
RLockGuard
()
{
lock_
.
rdunlock
();
}
TCRWLock
&
lock_
;
};
struct
RLockGuardWithTimeout
{
explicit
RLockGuardWithTimeout
(
TCRWLock
&
lock
,
const
int64_t
abs_timeout_us
,
int
&
ret
)
:
lock_
(
lock
),
need_unlock_
(
true
)
[[
nodiscard
]]
explicit
RLockGuardWithTimeout
(
TCRWLock
&
lock
,
const
int64_t
abs_timeout_us
,
int
&
ret
)
:
lock_
(
lock
),
need_unlock_
(
true
)
{
if
(
OB_FAIL
(
lock_
.
rdlock
(
abs_timeout_us
)))
{
need_unlock_
=
false
;
...
...
@@ -80,13 +80,13 @@ public:
};
struct
WLockGuard
{
explicit
WLockGuard
(
TCRWLock
&
lock
)
:
lock_
(
lock
)
{
lock_
.
wrlock
();
}
[[
nodiscard
]]
explicit
WLockGuard
(
TCRWLock
&
lock
)
:
lock_
(
lock
)
{
lock_
.
wrlock
();
}
~
WLockGuard
()
{
lock_
.
wrunlock
();
}
TCRWLock
&
lock_
;
};
struct
WLockGuardWithTimeout
{
explicit
WLockGuardWithTimeout
(
TCRWLock
&
lock
,
const
int64_t
abs_timeout_us
,
int
&
ret
)
:
lock_
(
lock
),
need_unlock_
(
true
)
[[
nodiscard
]]
explicit
WLockGuardWithTimeout
(
TCRWLock
&
lock
,
const
int64_t
abs_timeout_us
,
int
&
ret
)
:
lock_
(
lock
),
need_unlock_
(
true
)
{
if
(
OB_FAIL
(
lock_
.
wrlock
(
abs_timeout_us
)))
{
need_unlock_
=
false
;
...
...
@@ -106,7 +106,7 @@ public:
};
struct
WLockGuardWithRetry
{
explicit
WLockGuardWithRetry
(
TCRWLock
&
lock
,
const
int64_t
abs_timeout_us
)
:
lock_
(
lock
)
[[
nodiscard
]]
explicit
WLockGuardWithRetry
(
TCRWLock
&
lock
,
const
int64_t
abs_timeout_us
)
:
lock_
(
lock
)
{
lock_
.
wrlock_with_retry
(
abs_timeout_us
);
}
...
...
@@ -115,7 +115,7 @@ public:
};
struct
WLockGuardWithRetryInterval
{
explicit
WLockGuardWithRetryInterval
(
TCRWLock
&
lock
,
[[
nodiscard
]]
explicit
WLockGuardWithRetryInterval
(
TCRWLock
&
lock
,
const
int64_t
try_thresold_us
,
const
int64_t
retry_interval_us
)
:
lock_
(
lock
)
...
...
@@ -287,7 +287,7 @@ private:
class
TCWLockGuard
{
public:
explicit
TCWLockGuard
(
const
TCRWLock
&
lock
)
[[
nodiscard
]]
explicit
TCWLockGuard
(
const
TCRWLock
&
lock
)
:
lock_
(
const_cast
<
TCRWLock
&>
(
lock
)),
ret_
(
OB_SUCCESS
)
{
if
(
OB_UNLIKELY
(
OB_SUCCESS
!=
(
ret_
=
lock_
.
wrlock
())))
{
...
...
@@ -313,7 +313,7 @@ private:
class
TCRLockGuard
{
public:
explicit
TCRLockGuard
(
const
TCRWLock
&
lock
)
[[
nodiscard
]]
explicit
TCRLockGuard
(
const
TCRWLock
&
lock
)
:
lock_
(
const_cast
<
TCRWLock
&>
(
lock
)),
ret_
(
OB_SUCCESS
),
slot_id_
(
0
)
{
if
(
OB_UNLIKELY
(
OB_SUCCESS
!=
(
ret_
=
lock_
.
rdlock
(
INT64_MAX
,
slot_id_
))))
{
...
...
@@ -342,7 +342,7 @@ typedef TCRWLock RWLock;
class
RWLock
{
public:
struct
RLockGuard
[[
nodiscard
]]
struct
RLockGuard
{
explicit
RLockGuard
(
RWLock
&
lock
)
:
lock_
(
lock
)
{
lock_
.
rdlock
();
}
~
RLockGuard
()
{
lock_
.
rdunlock
();
}
...
...
@@ -350,7 +350,7 @@ public:
};
struct
RLockGuardWithTimeout
{
explicit
RLockGuardWithTimeout
(
RWLock
&
lock
,
const
int64_t
abs_timeout_us
,
int
&
ret
)
:
lock_
(
lock
),
need_unlock_
(
true
)
[[
nodiscard
]]
explicit
RLockGuardWithTimeout
(
RWLock
&
lock
,
const
int64_t
abs_timeout_us
,
int
&
ret
)
:
lock_
(
lock
),
need_unlock_
(
true
)
{
if
(
OB_FAIL
(
lock_
.
rdlock
(
abs_timeout_us
)))
{
need_unlock_
=
false
;
...
...
@@ -371,13 +371,13 @@ public:
struct
WLockGuard
{
explicit
WLockGuard
(
RWLock
&
lock
)
:
lock_
(
lock
)
{
lock_
.
wrlock
();
}
[[
nodiscard
]]
explicit
WLockGuard
(
RWLock
&
lock
)
:
lock_
(
lock
)
{
lock_
.
wrlock
();
}
~
WLockGuard
()
{
lock_
.
wrunlock
();
}
RWLock
&
lock_
;
};
struct
WLockGuardWithTimeout
{
explicit
WLockGuardWithTimeout
(
RWLock
&
lock
,
const
int64_t
abs_timeout_us
,
int
&
ret
)
:
lock_
(
lock
),
need_unlock_
(
true
)
[[
nodiscard
]]
explicit
WLockGuardWithTimeout
(
RWLock
&
lock
,
const
int64_t
abs_timeout_us
,
int
&
ret
)
:
lock_
(
lock
),
need_unlock_
(
true
)
{
if
(
OB_FAIL
(
lock_
.
wrlock
(
abs_timeout_us
)))
{
need_unlock_
=
false
;
...
...
@@ -397,7 +397,7 @@ public:
};
struct
WLockGuardWithRetry
{
explicit
WLockGuardWithRetry
(
RWLock
&
lock
,
const
int64_t
abs_timeout_us
)
:
lock_
(
lock
)
[[
nodiscard
]]
explicit
WLockGuardWithRetry
(
RWLock
&
lock
,
const
int64_t
abs_timeout_us
)
:
lock_
(
lock
)
{
lock_
.
wrlock_with_retry
(
abs_timeout_us
);
}
...
...
deps/oblib/src/lib/lock/threadmutex.h
浏览文件 @
69f20e8e
...
...
@@ -52,7 +52,7 @@ protected:
class
ThreadGuard
{
public:
ThreadGuard
(
ThreadMutex
*
mutex
)
[[
nodiscard
]]
ThreadGuard
(
ThreadMutex
*
mutex
)
{
mutex_
=
NULL
;
if
(
mutex
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录