summaryrefslogtreecommitdiff
path: root/tpool
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-06-23 13:20:25 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2022-06-23 13:20:25 +0300
commit5d0496c749dcdbed5974ccbd9f679a778982b4a8 (patch)
tree3a8d3d96affeece27cb180974a6ae3b55b672f0d /tpool
parent8ebff3bcb02e4185328542a2755e2f44e79465ec (diff)
parentf2f18e20ebfff2b744a08ba169bcedd1477b228c (diff)
downloadmariadb-git-5d0496c749dcdbed5974ccbd9f679a778982b4a8.tar.gz
Merge 10.6 into 10.7
Diffstat (limited to 'tpool')
-rw-r--r--tpool/tpool_generic.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/tpool/tpool_generic.cc b/tpool/tpool_generic.cc
index dfd780e7ea3..5d99783e8b9 100644
--- a/tpool/tpool_generic.cc
+++ b/tpool/tpool_generic.cc
@@ -327,21 +327,22 @@ public:
int m_period;
std::mutex m_mtx;
bool m_on;
- std::atomic<bool> m_running;
+ std::atomic<int> m_running;
void run()
{
/*
In rare cases, multiple callbacks can be scheduled,
- e.g with set_time(0,0) in a loop.
- We do not allow parallel execution, as user is not prepared.
+ at the same time,. e.g with set_time(0,0) in a loop.
+ We do not allow parallel execution, since it is against the expectations.
*/
- bool expected = false;
- if (!m_running.compare_exchange_strong(expected, true))
+ if (m_running.fetch_add(1, std::memory_order_acquire) > 0)
return;
-
- m_callback(m_data);
- m_running = false;
+ do
+ {
+ m_callback(m_data);
+ }
+ while (m_running.fetch_sub(1, std::memory_order_release) != 1);
if (m_pool && m_period)
{