From f913ba7a605b965359b437db36b0baa5498ec2c0 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 11 Jul 2012 13:39:56 +0400 Subject: [PATCH] MWL#182: Explain running statements: address review feedback - Make THD::check_killed() an inline function which makes calls to non-inline functions only whern there are APC requests to be served. --- sql/my_apc.h | 9 +++++++++ sql/sql_class.cc | 15 --------------- sql/sql_class.h | 9 ++++++++- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/sql/my_apc.h b/sql/my_apc.h index 1c4cc25376b..5473600bae6 100644 --- a/sql/my_apc.h +++ b/sql/my_apc.h @@ -53,6 +53,15 @@ public: void disable(); void process_apc_requests(); + /* + A lightweight function, intended to be used in frequent checks like this: + + if (apc_target.have_requests()) apc_target.process_apc_requests() + */ + inline bool have_apc_requests() + { + return test(apc_calls); + } /* Functor class for calls you can schedule */ class Apc_call diff --git a/sql/sql_class.cc b/sql/sql_class.cc index d6d14c45b47..414b1ba3f7f 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -2166,21 +2166,6 @@ void THD::rollback_item_tree_changes() } -/* - Check if the thread has been killed, and also process "APC requests" - - @retval true The thread is killed, execution should be interrupted - @retval false Not killed, continue execution -*/ - -bool THD::check_killed() -{ - if (killed) - return TRUE; - apc_target.process_apc_requests(); - return FALSE; -} - /***************************************************************************** ** Functions to provide a interface to select results *****************************************************************************/ diff --git a/sql/sql_class.h b/sql/sql_class.h index d34e285ead9..50e445fe9c4 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -2222,7 +2222,14 @@ public: */ killed_state volatile killed; - bool check_killed(); + inline bool check_killed() + { + if (killed) + return TRUE; + if (apc_target.have_apc_requests()) + apc_target.process_apc_requests(); + return FALSE; + } /* scramble - random string sent to client on handshake */ char scramble[SCRAMBLE_LENGTH+1];