YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
#ifndef MY_APC_STANDALONE
#include"mariadb.h" #include"sql_class.h"
#endif
/* For standalone testing of APC system, see unittest/sql/my_apc-t.cc */
if (enabled)
{ /* Create and post the request */
Call_request apc_request;
apc_request.call= call;
apc_request.processed= FALSE;
mysql_cond_init(key_show_explain_request_COND, &apc_request.COND_request,
NULL);
enqueue_request(&apc_request);
apc_request.what="enqueued by make_apc_call";
int wait_res= 0;
PSI_stage_info old_stage;
caller_thd->ENTER_COND(&apc_request.COND_request, LOCK_thd_kill_ptr,
&stage_show_explain, &old_stage); /* todo: how about processing other errors here? */ while (!apc_request.processed && (wait_res != ETIMEDOUT))
{ /* We own LOCK_thd_kill_ptr */
wait_res= mysql_cond_timedwait(&apc_request.COND_request,
LOCK_thd_kill_ptr, &abstime); // &apc_request.LOCK_request, &abstime); if (caller_thd->killed) break;
}
if (!apc_request.processed)
{ /* Thewaithastimedout,orthisthreadwasKILLed. Removetherequestfromthequeue(oktodobecauseweown LOCK_thd_kill_ptr)
*/
apc_request.processed= TRUE;
dequeue_request(&apc_request);
*timed_out= TRUE;
res= TRUE;
} else
{ /* Request was successfully executed and dequeued by the target thread */
res= FALSE;
} /* exit_cond()willcallmysql_mutex_unlock(LOCK_thd_kill_ptr)forus:
*/
caller_thd->EXIT_COND(&old_stage);
/* Destroy all APC request data */
mysql_cond_destroy(&apc_request.COND_request);
} else
{ #ifndef DBUG_OFF /* We didn't make the call, because the target is disabled */
n_calls_processed++; #endif
mysql_mutex_unlock(LOCK_thd_kill_ptr);
} return res;
}
void Apc_target::process_apc_requests(bool force)
{ while (1)
{
Call_request *request;
if (force)
mysql_mutex_lock(LOCK_thd_kill_ptr); elseif (mysql_mutex_trylock(LOCK_thd_kill_ptr)) break; // Mutex is blocked, try again later if (!(request= get_first_in_queue()))
{ /* No requests in the queue */
mysql_mutex_unlock(LOCK_thd_kill_ptr); break;
}
/* Removetherequestfromthequeue(we'reholdingqueuelocksowecanbe surethatrequestownerwon'ttrytoremoveit)
*/
request->what="dequeued by process_apc_requests";
dequeue_request(request);
request->processed= TRUE;
request->call->call_in_target_thread();
request->what="func called by process_apc_requests";
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.