Commit 58c3e32d authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Simplify thd_wait_begin. given how seldom they are called, calling current_thd...

Simplify thd_wait_begin. given how seldom they are called, calling current_thd one more time  is not going to be anything performance relevant.

Also use thd_wait_begin/end for thr_lock and sync callbacks.
parent 2a5d8ea9
......@@ -46,28 +46,20 @@ static bool no_threads_end(THD *thd, bool put_in_cache)
/**@{*/
extern "C"
{
static void scheduler_wait_lock_begin(void) {
THD *thd=current_thd;
if(thd)
MYSQL_CALLBACK(thd->scheduler, thd_wait_begin, (thd, THD_WAIT_TABLE_LOCK));
static void scheduler_wait_lock_begin(void) {
thd_wait_begin(NULL, THD_WAIT_TABLE_LOCK);
}
static void scheduler_wait_lock_end(void) {
THD *thd=current_thd;
if(thd)
MYSQL_CALLBACK(thd->scheduler, thd_wait_end, (thd));
thd_wait_end(NULL);
}
static void scheduler_wait_sync_begin(void) {
THD *thd=current_thd;
if(thd)
MYSQL_CALLBACK(thd->scheduler, thd_wait_begin, (thd, THD_WAIT_TABLE_LOCK));
thd_wait_begin(NULL, THD_WAIT_SYNC);
}
static void scheduler_wait_sync_end(void) {
THD *thd=current_thd;
if(thd)
MYSQL_CALLBACK(thd->scheduler, thd_wait_end, (thd));
thd_wait_end(NULL);
}
};
/**@}*/
......
......@@ -3935,13 +3935,10 @@ extern "C" bool thd_sqlcom_can_generate_row_events(const MYSQL_THD thd)
*/
extern "C" void thd_wait_begin(MYSQL_THD thd, int wait_type)
{
if (unlikely(!thread_scheduler) || !thread_scheduler->thd_wait_begin)
return;
if (thd == NULL)
if (!thd)
{
thd=current_thd;
if(unlikely(thd == NULL))
thd= current_thd;
if (unlikely(!thd))
return;
}
MYSQL_CALLBACK(thd->scheduler, thd_wait_begin, (thd, wait_type));
......@@ -3956,16 +3953,13 @@ extern "C" void thd_wait_begin(MYSQL_THD thd, int wait_type)
*/
extern "C" void thd_wait_end(MYSQL_THD thd)
{
if (unlikely(!thread_scheduler) || ! thread_scheduler->thd_wait_begin)
return;
if (thd == NULL)
if (!thd)
{
thd=current_thd;
if(unlikely(thd == NULL))
thd= current_thd;
if (unlikely(!thd))
return;
}
if(likely(thd->scheduler == thread_scheduler))
thread_scheduler->thd_wait_end(thd);
MYSQL_CALLBACK(thd->scheduler, thd_wait_end, (thd));
}
#endif // INNODB_COMPATIBILITY_HOOKS */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment