innodb purge--srv_worker_thread
原创
©著作权归作者所有:来自51CTO博客作者yzs的专栏的原创作品,请联系作者获取转载授权,否则将追究法律责任
1、将trh放到srv_sys->tasks队列
srv_que_task_enqueue_low:
UT_LIST_ADD_LAST(queue, srv_sys->tasks, thr);
srv_release_threads(SRV_WORKER, 1);
slot->suspended = FALSE;
释放一个srv_slot:os_event_set(slot->event);
slot = &srv_sys->sys_threads[i];,i从0开始,找一个挂起的slot。
2、srv_worker_thread
srv_worker_thread:
do {
srv_suspend_thread(slot);// slot->suspended = TRUE;
os_event_wait(slot->event);//等待os_event_set
if (srv_task_execute()) {//fetch task from queue and run purge
/* If there are tasks in the queue, wakeup the purge coordinator thread. */
srv_wake_purge_thread_if_not_active();
}
/* Note: we are checking the state without holding the purge_sys->latch here. */
} while (purge_sys->state != PURGE_STATE_EXIT);
purge_sys->state在协调线程退出时置成PURGE_STATE_EXIT,所以worker线程是在协调线程退出后才退出