summaryrefslogtreecommitdiff
path: root/sql/event_scheduler.cc
diff options
context:
space:
mode:
authorMikael Ronstrom <mikael@mysql.com>2009-10-12 11:00:39 +0200
committerMikael Ronstrom <mikael@mysql.com>2009-10-12 11:00:39 +0200
commitbae553cfcd9ad8b9df8b5305736f6810fbaed43b (patch)
treeb9c258d33b8f1dd330ba73287a648ffbd20488d7 /sql/event_scheduler.cc
parenta4785fc4a2abeb3f8fbc253b78f558540b949482 (diff)
downloadmariadb-git-bae553cfcd9ad8b9df8b5305736f6810fbaed43b.tar.gz
Backported my_atomic from 6.0-codebase and added support for 64-bit atomics to enable removal of LOCK_thread_count from every query, removed LOCK_thread_count from use in dispatch_command and close of query which is used in every query, now uses atomic increments/decrements instead
Diffstat (limited to 'sql/event_scheduler.cc')
-rw-r--r--sql/event_scheduler.cc17
1 files changed, 12 insertions, 5 deletions
diff --git a/sql/event_scheduler.cc b/sql/event_scheduler.cc
index 8c0025f9ed4..9c825078370 100644
--- a/sql/event_scheduler.cc
+++ b/sql/event_scheduler.cc
@@ -132,9 +132,10 @@ post_init_event_thread(THD *thd)
pthread_mutex_lock(&LOCK_thread_count);
threads.append(thd);
thread_count++;
- thread_running++;
pthread_mutex_unlock(&LOCK_thread_count);
-
+ my_atomic_rwlock_wrlock(&global_query_id_lock);
+ inc_thread_running();
+ my_atomic_rwlock_wrunlock(&global_query_id_lock);
return FALSE;
}
@@ -156,10 +157,12 @@ deinit_event_thread(THD *thd)
DBUG_PRINT("exit", ("Event thread finishing"));
pthread_mutex_lock(&LOCK_thread_count);
thread_count--;
- thread_running--;
delete thd;
pthread_cond_broadcast(&COND_thread_count);
pthread_mutex_unlock(&LOCK_thread_count);
+ my_atomic_rwlock_wrlock(&global_query_id_lock);
+ dec_thread_running();
+ my_atomic_rwlock_wrunlock(&global_query_id_lock);
}
@@ -417,10 +420,12 @@ Event_scheduler::start()
net_end(&new_thd->net);
pthread_mutex_lock(&LOCK_thread_count);
thread_count--;
- thread_running--;
delete new_thd;
pthread_cond_broadcast(&COND_thread_count);
pthread_mutex_unlock(&LOCK_thread_count);
+ my_atomic_rwlock_wrlock(&global_query_id_lock);
+ dec_thread_running();
+ my_atomic_rwlock_wrunlock(&global_query_id_lock);
}
end:
UNLOCK_DATA();
@@ -550,10 +555,12 @@ error:
net_end(&new_thd->net);
pthread_mutex_lock(&LOCK_thread_count);
thread_count--;
- thread_running--;
delete new_thd;
pthread_cond_broadcast(&COND_thread_count);
pthread_mutex_unlock(&LOCK_thread_count);
+ my_atomic_rwlock_wrlock(&global_query_id_lock);
+ dec_thread_running();
+ my_atomic_rwlock_wrunlock(&global_query_id_lock);
}
delete event_name;
DBUG_RETURN(TRUE);