Browse Source

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

pull/1434/head
Vladislav Vaintroub 6 years ago
parent
commit
bada05a883
  1. 10
      storage/innobase/srv/srv0srv.cc
  2. 16
      tpool/task.cc
  3. 1
      tpool/task_group.cc
  4. 13
      tpool/tpool.h
  5. 2
      tpool/tpool_generic.cc
  6. 1
      tpool/tpool_win.cc

10
storage/innobase/srv/srv0srv.cc

@ -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
}

16
tpool/task.cc

@ -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();
}
}

1
tpool/task_group.cc

@ -53,6 +53,7 @@ namespace tpool
if (t)
{
t->m_func(t->m_arg);
dbug_execute_after_task_callback();
t->release();
}
lk.lock();

13
tpool/tpool.h

@ -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:

2
tpool/tpool_generic.cc

@ -293,7 +293,7 @@ public:
return;
m_callback(m_data);
dbug_execute_after_task_callback();
m_running = false;
if (m_pool && m_period)

1
tpool/tpool_win.cc

@ -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);
}

Loading…
Cancel
Save