File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -30,9 +30,7 @@ ConnectionState::~ConnectionState() {
30
30
}
31
31
32
32
void ConnectionState::clearLock () {
33
- if (!workQueue.empty ()) {
34
- waitFinished ();
35
- }
33
+ waitFinished ();
36
34
_currentLockId = EMPTY_LOCK_ID;
37
35
}
38
36
@@ -47,9 +45,7 @@ bool ConnectionState::matchesLock(const ConnectionLockId &lockId) {
47
45
bool ConnectionState::isEmptyLock () { return _currentLockId == EMPTY_LOCK_ID; }
48
46
49
47
void ConnectionState::close () {
50
- if (!workQueue.empty ()) {
51
- waitFinished ();
52
- }
48
+ waitFinished ();
53
49
// So that the thread can stop (if not already)
54
50
threadDone = true ;
55
51
sqlite3_close_v2 (connection);
@@ -94,12 +90,18 @@ void ConnectionState::doWork() {
94
90
--threadBusy;
95
91
// Need to notify in order for waitFinished to be updated when
96
92
// the queue is empty and not busy
93
+ {
94
+ std::unique_lock<std::mutex> g (workQueueMutex);
97
95
workQueueConditionVariable.notify_all ();
96
+ }
98
97
}
99
98
}
100
99
101
100
void ConnectionState::waitFinished () {
102
101
std::unique_lock<std::mutex> g (workQueueMutex);
102
+ if (workQueue.empty ()) {
103
+ return ;
104
+ }
103
105
workQueueConditionVariable.wait (
104
106
g, [&] { return workQueue.empty () && (threadBusy == 0 ); });
105
107
}
You can’t perform that action at this time.
0 commit comments