YoushouldhavereceivedacopyoftheGNUGeneralPublicLicense alongwiththisprogram;ifnot,writetotheFreeSoftware
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
/* OneAPCrequest(towrite'value'into*where_to)
*/ class Apc_order : public Apc_target::Apc_call
{ public: int value; // The value int *where_to; // Where to write it
Apc_order(int a, int *b) : value(a), where_to(b) {}
while (!requestors_should_exit)
{ int dst_value= 0; int src_value= int_rand(4*1000*100); /* Create an APC to do "dst_value= src_value" assignment */
Apc_order apc_order(src_value, &dst_value); bool timed_out;
mysql_mutex_lock(&target_mutex); bool res= apc_target.make_apc_call(&my_thd, &apc_order, 60, &timed_out); if (res)
{ if (timed_out)
increment_counter(&apcs_timed_out); else
increment_counter(&apcs_missed);
if (dst_value != 0)
{
diag("APC was done even though return value says it wasnt!");
have_errors= true;
}
} else
{ if (dst_value != src_value)
{
diag("APC was not done even though return value says it was!");
have_errors= true;
}
} //my_sleep(300);
}
diag("test_apc_requestor_thread exiting");
my_thread_end(); return NULL;
}
/* Number of APC requestor threads */ constint N_THREADS=23;
int main(int args, char **argv)
{
pthread_t service_thr;
pthread_t request_thr[N_THREADS]; int i;
plan(1);
diag("Testing APC delivery and execution");
pthread_create(&service_thr, NULL, test_apc_service_thread, (void*)NULL); while (!started)
my_sleep(1000); for (i = 0; i < N_THREADS; i++)
pthread_create(&request_thr[i], NULL, test_apc_requestor_thread, (void*)NULL);
for (i = 0; i < 15; i++)
{
my_sleep(500*1000);
diag("%d APCs served %d missed", apcs_served, apcs_missed);
}
diag("Shutting down requestors");
requestors_should_exit= TRUE; for (i = 0; i < N_THREADS; i++)
pthread_join(request_thr[i], NULL);
diag("Shutting down service");
service_should_exit= TRUE;
pthread_join(service_thr, NULL);
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.