FDataScannerImpl::FDataScannerImpl(const uint64 InDataOffset, const TArray<uint8>& InData, const FCloudEnumerationRef& InCloudEnumeration, const FDataMatcherRef& InDataMatcher, const FStatsCollectorRef& InStatsCollector) : DataStartOffset(InDataOffset) , Data(InData) , CloudEnumeration(InCloudEnumeration) , DataMatcher(InDataMatcher) , StatsCollector(InStatsCollector) , bIsComplete(false) , bShouldAbort(false) { // Create statistics StatCreatedScanners = StatsCollector->CreateStat(TEXT("Scanner: Created Scanners"), EStatFormat::Value); StatRunningScanners = StatsCollector->CreateStat(TEXT("Scanner: Running Scanners"), EStatFormat::Value); StatCpuTime = StatsCollector->CreateStat(TEXT("Scanner: CPU Time"), EStatFormat::Timer); StatConsumeBytesTime = StatsCollector->CreateStat(TEXT("Scanner: Consume Bytes Time"), EStatFormat::Timer); StatFindMatchTime = StatsCollector->CreateStat(TEXT("Scanner: Find Match Time"), EStatFormat::Timer); StatDataMatchTime = StatsCollector->CreateStat(TEXT("Scanner: Data Match Time"), EStatFormat::Timer); StatChunkWriterTime = StatsCollector->CreateStat(TEXT("Scanner: Chunk Writer Time"), EStatFormat::Timer); StatHashCollisions = StatsCollector->CreateStat(TEXT("Scanner: Hash Collisions"), EStatFormat::Value); StatChunkDataChecks = StatsCollector->CreateStat(TEXT("Scanner: Chunk Data Checks"), EStatFormat::Value); StatChunkDataMatches = StatsCollector->CreateStat(TEXT("Scanner: Chunk Data Matches"), EStatFormat::Value); StatMissingChunks = StatsCollector->CreateStat(TEXT("Scanner: Missing Chunks"), EStatFormat::Value); StatMatchedData = StatsCollector->CreateStat(TEXT("Scanner: Matched Data"), EStatFormat::DataSize); StatExtraData = StatsCollector->CreateStat(TEXT("Scanner: Extra Data"), EStatFormat::DataSize); // Queue thread NumIncompleteScanners.Increment(); TFunction<FDataScanResult()> Task = [this]() { FDataScanResult Result = ScanData(); FDataScannerImpl::NumIncompleteScanners.Decrement(); return MoveTemp(Result); }; FutureResult = Async(EAsyncExecution::ThreadPool, Task); }
//----------------------------------------------------------------------------- ScanData ScanDataReceiver::getFullScan() { std::unique_lock<std::mutex> lock(data_mutex_); while( checkConnection() && isConnected() && scan_data_.size()<2 ) { data_notifier_.wait_for(lock, std::chrono::seconds(1)); } ScanData data; if( scan_data_.size() >= 2 && isConnected() ) { data = ScanData(std::move(scan_data_.front())); scan_data_.pop_front(); } return data; }
/* Start main function */ int main(void) { /* Declare variables */ char op; /* User-input operator */ double input; /* User-given numerical input */ double total; /* Total result of the calculation thus far */ /* Initialize some things */ total = 0; op = 'a'; /* Start loop, ends when q is the operator */ do { /* Initialize input in loop for error check */ input = -9000; /* Get input with scan_data function */ ScanData(&op, &input); /* Error check, input must be a number */ if (input != -9000) { /* Either quit or do as the user wants */ if (op == '+' || op == '-' || op == '*' || op == '/' || op == '^') { total = DoNextOp(op, input, total); printf("result so far is %.1f\n", total); } else if (op == 'q') { printf("final result is %.1f\n", total); } else { printf("Error: Invalid operator\n"); } } else { printf("Error: Invalid input\n"); } } while (op != 'q'); /* End loop when q is the operator */ return(0); }