本文整理汇总了C++中MyServer::adjust_job_count_estimate方法的典型用法代码示例。如果您正苦于以下问题:C++ MyServer::adjust_job_count_estimate方法的具体用法?C++ MyServer::adjust_job_count_estimate怎么用?C++ MyServer::adjust_job_count_estimate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyServer
的用法示例。
在下文中一共展示了MyServer::adjust_job_count_estimate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FireUpJobs
void FireUpJobs( MyServer& server, MyClient& client, int n_thread, int n_extra, Checker* checker ) {
REMARK("client %d: calling adjust_job_count_estimate(%d)\n", client.client_id(),n_thread);
// Exercise independent_thread_number_changed, even for zero values.
server.independent_thread_number_changed( n_extra );
#if _WIN32||_WIN64
::rml::server::execution_resource_t me;
server.register_master( me );
#endif /* _WIN32||_WIN64 */
// Experiments indicate that when oversubscribing, the main thread should wait a little
// while for the RML worker threads to do some work.
if( checker ) {
// Give RML time to respond to change in number of threads.
Harness::Sleep(1);
for( int k=0; k<n_thread; ++k )
client.job_array[k].processing_count = 0;
}
//close the gate to keep worker threads from returning to RML until a snapshot is taken
client.close_the_gate();
server.adjust_job_count_estimate( n_thread );
int n_used = 0;
if( checker ) {
Harness::Sleep(100);
for( int k=0; k<n_thread; ++k )
if( client.job_array[k].processing_count )
++n_used;
}
// open the gate
client.open_the_gate();
// Logic further below presumes that jobs never starve, so undo previous call
// to independent_thread_number_changed before waiting on those jobs.
server.independent_thread_number_changed( -n_extra );
REMARK("client %d: wait for each job to be processed at least once\n",client.client_id());
// Calculate the number of jobs that are expected to get threads.
int expected = n_thread;
// Wait for expected number of jobs to be processed.
#if RML_USE_WCRM
int default_concurrency = server.default_concurrency();
if( N_TestConnections>0 ) {
if( default_concurrency+1>=8 && n_thread<=3 && N_TestConnections<=3 && (default_concurrency/int(N_TestConnections)-1)>=n_thread ) {
#endif /* RML_USE_WCRM */
for(;;) {
int n = 0;
for( int k=0; k<n_thread; ++k )
if( client.job_array[k].processing_count!=0 )
++n;
if( n>=expected ) break;
server.yield();
}
#if RML_USE_WCRM
} else if( n_thread>0 ) {
for( int m=0; m<20; ++m ) {
int n = 0;
for( int k=0; k<n_thread; ++k )
if( client.job_array[k].processing_count!=0 )
++n;
if( n>=expected ) break;
Harness::Sleep(1);
}
}
}
#endif /* RML_USE_WCRM */
server.adjust_job_count_estimate(-n_thread);
#if _WIN32||_WIN64
server.unregister_master( me );
#endif
// Give RML some time to respond
if( checker ) {
Harness::Sleep(1);
checker->check_number_of_threads_delivered( n_used, n_thread, n_extra );
}
}