Commit bada05a8 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

tpool - implement post-task callback (for Innodb debugging)

parent 90002480
......@@ -714,6 +714,13 @@ static void thread_pool_thread_end()
}
#ifndef DBUG_OFF
static void dbug_after_task_callback()
{
ut_ad(!sync_check_iterate(sync_check()));
}
#endif
void srv_thread_pool_init()
{
DBUG_ASSERT(!srv_thread_pool);
......@@ -725,6 +732,9 @@ void srv_thread_pool_init()
#endif
srv_thread_pool->set_thread_callbacks(thread_pool_thread_init,
thread_pool_thread_end);
#ifndef DBUG_OFF
tpool::set_after_task_callback(dbug_after_task_callback);
#endif
}
......
......@@ -21,6 +21,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 - 1301 USA*/
namespace tpool
{
#ifndef DBUG_OFF
static callback_func_np after_task_callback;
void set_after_task_callback(callback_func_np cb)
{
after_task_callback= cb;
}
void execute_after_task_callback()
{
if (after_task_callback)
after_task_callback();
}
#endif
task::task(callback_func func, void* arg, task_group* group) :
m_func(func), m_arg(arg), m_group(group) {}
......@@ -35,6 +50,7 @@ namespace tpool
{
/* Execute directly. */
m_func(m_arg);
dbug_execute_after_task_callback();
release();
}
}
......
......@@ -53,6 +53,7 @@ namespace tpool
if (t)
{
t->m_func(t->m_arg);
dbug_execute_after_task_callback();
t->release();
}
lk.lock();
......
......@@ -51,6 +51,7 @@ namespace tpool
Task callback function
*/
typedef void (*callback_func)(void *);
typedef void (*callback_func_np)(void);
class task;
/** A class that can be used e.g. for
......@@ -174,6 +175,18 @@ class thread_pool;
extern aio *create_simulated_aio(thread_pool *tp);
#ifndef DBUG_OFF
/*
This function is useful for debugging to make sure all mutexes are released
inside a task callback
*/
void set_after_task_callback(callback_func_np cb);
void execute_after_task_callback();
#define dbug_execute_after_task_callback() execute_after_task_callback()
#else
#define dbug_execute_after_task_callback() do{}while(0)
#endif
class thread_pool
{
protected:
......
......@@ -293,7 +293,7 @@ class thread_pool_generic : public thread_pool
return;
m_callback(m_data);
dbug_execute_after_task_callback();
m_running = false;
if (m_pool && m_period)
......
......@@ -93,6 +93,7 @@ class thread_pool_win : public thread_pool
return;
}
timer->m_func(timer->m_data);
dbug_execute_after_task_callback();
if (timer->m_period)
timer->set_time(timer->m_period, timer->m_period);
}
......
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