WL#5276: plugin service: thread pool callbacks

Affects: Server-5.5   —   Status: In-Progress   —   Priority: Medium


In order to be able to implement different thread pool / connection pool
managers, a service to register the necessary thread pool callbacks needs to be


Add plugin service to be able to register thread pool implementations from
shared libraries.

The worklog adds two services to the server: one to allow plugins to yield
processing to other connections and one to allow the thread scheduler to be set.


This is an enumeration used by the ``thd_wait`` service and give information
about the reason for the thread to stall.

  ======================== =============================================
  Symbol                   Description
  ======================== =============================================
  THD_WAIT_MUTEX           The thread is going to wait for a mutex
  THD_WAIT_DISKIO          The thread is going to do some Disk I/O
  THD_WAIT_ROW_TABLE_LOCK  The thread is going to wait for a row lock
  THD_WAIT_GLOBAL_LOCK     The thread is going to wait for a global lock
  ======================== =============================================


This service is used to notify the thread scheduler that the thread is going to
go to sleep or stall, or that it is resuming execution. The interface consists
of two functions:

void thd_wait_begin(MYSQL_THD thd, thd_wait_type wait_type)
  This function can be called to inform the scheduler that this thread
  is going to stall for some reason. This will allow a thread scheduler
  to spawn a second thread to replace the one that goes to sleep.

void thd_wait_end(MYSQL_THD thd)
  This function is called to inform the scheduler that this thread has
  resumed execution after the wait.


This service is used to install an alternative thread scheduler by a plug-in.
The thread schedulers should be loaded using the start-up option plugin-load and
not using the INSTALL PLUGIN command. If the command is used, odd things might

int my_thread_scheduler_set(struct scheduler_functions *scheduler)
  Set the thread scheduler to use for scheduling and save away
  the existing one.

int my_thread_scheduler_reset()
  Restore the thread scheduler to the saved thread scheduler.