make ObQSyncLock read priority
This commit is contained in:
parent
26e1fb4b74
commit
5e391b5bea
11
deps/oblib/src/lib/lock/ob_qsync_lock.cpp
vendored
11
deps/oblib/src/lib/lock/ob_qsync_lock.cpp
vendored
@ -50,11 +50,16 @@ int ObQSyncLock::wrlock()
|
||||
if (!ATOMIC_BCAS(&write_flag_, 0, 1)) {
|
||||
sched_yield();
|
||||
} else {
|
||||
// write priority try sync to succ
|
||||
while (!qsync_.try_sync()) {
|
||||
bool sync_success = false;
|
||||
for (int64_t i = 0; !sync_success && i < TRY_SYNC_COUNT; i++) {
|
||||
sync_success = qsync_.try_sync();
|
||||
}
|
||||
if (sync_success) {
|
||||
break;
|
||||
} else {
|
||||
ATOMIC_STORE(&write_flag_, 0);
|
||||
sched_yield();
|
||||
}
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
return common::OB_SUCCESS;
|
||||
|
2
deps/oblib/src/lib/lock/ob_qsync_lock.h
vendored
2
deps/oblib/src/lib/lock/ob_qsync_lock.h
vendored
@ -33,6 +33,8 @@ public:
|
||||
int wrlock();
|
||||
void wrunlock();
|
||||
int try_rdlock();
|
||||
private:
|
||||
static const int64_t TRY_SYNC_COUNT = 16;
|
||||
private:
|
||||
int64_t write_flag_ CACHE_ALIGNED;
|
||||
common::ObDynamicQSync qsync_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user