本文整理汇总了C++中Target::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ Target::Close方法的具体用法?C++ Target::Close怎么用?C++ Target::Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Target
的用法示例。
在下文中一共展示了Target::Close方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Do_IOs
//
// Performing accesses based on specifications to targets.
// The following function initiates I/O, recording performance information only when the
// grunt is in the TestRecording state. The function needs to be as efficient as possible
// while still being readable and maintainable.
//
// "data" is the location of data to use for transfers.
//
void Grunt::Do_IOs()
{
////////////////////////////////////////////////////////////////////////////
// these are working variables for the IO loop - they aren't referenced
// outside of it and their values don't span more than one burst of data.
//
int remaining_transactions_in_burst=0; // how's that for a name?
int access_percent = 0; // Determines the access spec.
int target_id; // Index into target array of target to access.
DWORD size; // Size of transfer request to target.
int transfer_delay; // Milliseconds to wait before accessing.
ReturnVal transfer_result; // Success/failure result of read or write operation.
Transaction* transaction = NULL; // Pointer to the transaction being processed.
DWORD user_alignment;
DWORDLONG user_align_mask;
DWORD reply; // Size of reply, or 0 for no reply
DWORDLONG conn_time; // Used to calculate average and max connection times.
Target* target;
Raw_Result *target_results; // Pointer to results for selected target.
Raw_Result *prev_target_results;
while ( grunt_state != TestIdle )
{
#if defined(IOMTR_OSFAMILY_NETWARE)
pthread_yield(); // NetWare is non-preemptive
#elif defined(IOMTR_OSFAMILY_UNIX) || defined(IOMTR_OSFAMILY_WINDOWS)
// nop
#else
#warning ===> WARNING: You have to do some coding here to get the port done!
#endif
// If we can't queue another request, wait for a completion.
// If we CAN queue another request, get only one completion and do
// so immediately (with a time out of 0).
Complete_IO( ( available_head == available_tail ||
target_count == targets_closing_count ) ? TIMEOUT_TIME : 0 );
// Now check to see if there really are any completed requests.
// Complete_IO may not have freed a slot in the available queue.
if ( available_head == available_tail )
continue; // repeat the outermost while loop
// Getting an index into the target array of the next target to access.
target_id = trans_slots[available_trans_queue[available_head]].target_id;
target = targets[target_id];
// Checking the next target to access to see if it is closing.
// This if statement is separated from the one below for performance.
if ( target->spec.test_connection_rate && target->is_closing )
{
// Target is closing. Move it to the tail of the available queue.
available_trans_queue[available_tail++] =
available_trans_queue[available_head++];
if ( available_head > cur_trans_slots ) {
available_head = 0;
}
if ( available_tail > cur_trans_slots ) {
available_tail = 0;
}
// Check to see if we can close the target. Targets are not closed
// until all outstanding I/Os have completed.
if ( target->outstanding_ios == 0 )
{
#if _DEBUG
cout << "Testing connection rate: Closing "
<< targets[target_id]->spec.name << endl;
#endif
// Close target and record connection time.
target->Close( &grunt_state );
conn_time = rdtsc() - target->conn_start_time;
// Since target is closed, it is no longer closing.
target->is_closing = FALSE;
// Record connection latencies.
if ( ramp_up_ios_pending <= 0 && grunt_state == TestRecording )
{
target_results = &(worker_performance.target_results.result[target_id]);
target_results->connection_count++;
target_results->connection_latency_sum += conn_time;
if ( conn_time > target_results->max_raw_connection_latency )
target_results->max_raw_connection_latency = conn_time;
prev_target_results = &(prev_worker_performance.target_results.result[target_id]);
if ( conn_time > prev_target_results->max_raw_connection_latency )
prev_target_results->max_raw_connection_latency = conn_time;
}
}
continue;
}
//.........这里部分代码省略.........