MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->setFixedSize(400, 200); bouton = new QPushButton("Find", this); layout = new QHBoxLayout; zone1 = new QTextEdit(this); zone2 = new QTextEdit(this); zone3 = new QTextEdit(this); erase = new QPushButton("clear", this); msgBox = new QMessageBox(this); msgBox->setText("Erreur..."); msgBox->setStandardButtons(QMessageBox::Ok); msgBox->setIcon(QMessageBox::Warning); msgBox->setWindowTitle("Erreur..."); erase->setVisible(false); zone3->setReadOnly(true); layout->addWidget(bouton); layout->addWidget(zone1); layout->addWidget(zone2); layout->addWidget(zone3); const int w_bouton = 60; const int h_bouton = 20; const int w_zone = 80; const int h_zone = 25; bouton->setFixedSize(w_bouton, h_bouton); erase->setFixedSize(w_bouton, h_bouton); zone1->setFixedSize(w_zone, h_zone); zone2->setFixedSize(w_zone, h_zone); zone3->setFixedSize(w_zone, h_zone); bouton->move(220, 60); erase->move(220, 60); zone1->move(20, 60); zone2->move(120, 60); zone3->move(300, 60); connect(bouton, SIGNAL(clicked()), this, SLOT(task())); connect(erase, SIGNAL(clicked()), this, SLOT(task2())); }
void ChartControl::OnPaint(Canvas &canvas) { assert(glide_computer != NULL); const ComputerSettings &settings_computer = blackboard->GetComputerSettings(); const MapSettings &settings_map = blackboard->GetMapSettings(); const MoreData &basic = blackboard->Basic(); const DerivedInfo &calculated = blackboard->Calculated(); #ifdef ENABLE_OPENGL /* enable clipping */ GLCanvasScissor scissor(canvas); #endif canvas.clear(COLOR_WHITE); canvas.SetTextColor(COLOR_BLACK); PixelRect rcgfx = get_client_rect(); // background is painted in the base-class switch (page) { case ANALYSIS_PAGE_BAROGRAPH: RenderBarograph(canvas, rcgfx, chart_look, look->cross_section, glide_computer->GetFlightStats(), basic, calculated, protected_task_manager); break; case ANALYSIS_PAGE_CLIMB: RenderClimbChart(canvas, rcgfx, chart_look, glide_computer->GetFlightStats(), settings_computer.polar.glide_polar_task); break; case ANALYSIS_PAGE_THERMAL_BAND: { OrderedTaskBehaviour otb; if (protected_task_manager != NULL) { otb = protected_task_manager->GetOrderedTaskBehaviour(); } ThermalBandRenderer renderer(thermal_band_look, chart_look); renderer.DrawThermalBand(basic, calculated, settings_computer, canvas, rcgfx, settings_computer.task, false, &otb); } break; case ANALYSIS_PAGE_WIND: RenderWindChart(canvas, rcgfx, chart_look, glide_computer->GetFlightStats(), basic, glide_computer->GetWindStore()); break; case ANALYSIS_PAGE_POLAR: RenderGlidePolar(canvas, rcgfx, look->chart, calculated.climb_history, settings_computer, settings_computer.polar.glide_polar_task); break; case ANALYSIS_PAGE_TEMPTRACE: RenderTemperatureChart(canvas, rcgfx, chart_look, glide_computer->GetCuSonde()); break; case ANALYSIS_PAGE_TASK: if (protected_task_manager != NULL) { const TraceComputer *trace_computer = glide_computer != NULL ? &glide_computer->GetTraceComputer() : NULL; const FlightStatisticsRenderer fs(glide_computer->GetFlightStats(), chart_look, look->map); fs.RenderTask(canvas, rcgfx, basic, calculated, settings_computer, settings_map, *protected_task_manager, trace_computer); } break; case ANALYSIS_PAGE_OLC: if (glide_computer != NULL) { const FlightStatisticsRenderer fs(glide_computer->GetFlightStats(), chart_look, look->map); fs.RenderOLC(canvas, rcgfx, basic, calculated, settings_computer, settings_map, calculated.contest_stats, glide_computer->GetTraceComputer()); } break; case ANALYSIS_PAGE_TASK_SPEED: if (protected_task_manager != NULL) { ProtectedTaskManager::Lease task(*protected_task_manager); RenderSpeed(canvas, rcgfx, chart_look, glide_computer->GetFlightStats(), basic, calculated, task); } break; default: // should never get here! break; } }
void Scheduler::manageExecution( std::unique_ptr<SysManager> const& sysManager, std::unique_ptr<StateManager> const& stateManager) { stateManager->processRequests(); uint_fast32_t sysId; ExecutionDesc* execDesc; if (!_finished.empty()) { while (_finished.try_pop(sysId)) { stateManager->distributeFrom(sysId); execDesc = &sysManager->getExecutionDesc(sysId); if (execDesc->getExecution() == Execution::RECURRING) { _scheduledSystems.add(sysId); } } } if (!_toSchedule.empty()) { while (_toSchedule.try_pop(sysId)) { _scheduledSystems.add(sysId); } } for (uint_fast32_t i = 0; i < _scheduledSystems.size(); ++i) { sysId = _scheduledSystems[i]; execDesc = &sysManager->getExecutionDesc(sysId); if (execDesc->isTimeToStart()) { stateManager->distributeTo(sysId); if (execDesc->getMode() == Mode::ASYNC) { execDesc->resetStartTime(); std::function<void()> const& procedure = sysManager->getSystem(sysId)->getExecutionProcedure(); AsyncTask* task = new (tbb::task::allocate_root())NLE::Core::AsyncTask(*this, sysId, procedure); switch (execDesc->getPriority()) { case Priority::LOW: tbb::task::enqueue(*task, tbb::priority_low); break; case Priority::STANDARD: tbb::task::enqueue(*task, tbb::priority_normal); break; case Priority::HIGH: tbb::task::enqueue(*task, tbb::priority_high); break; default: //should never be reached assert(false); } } else { _syncSystemsToRun.push_back(sysId); } _scheduledSystems.itRemove(i); } } if (_syncSystemsToRun.size() > 0) { for (uint_fast32_t sysId : _syncSystemsToRun) { execDesc = &sysManager->getExecutionDesc(sysId); execDesc->resetStartTime(); std::function<void()> const& procedure = sysManager->getSystem(sysId)->getExecutionProcedure(); SyncTask task(*this, sysId, procedure); task.execute(); } _syncSystemsToRun.clear(); } }
void Downloader::doDownloadNode (Node& node, const boost::filesystem::path& path) { if (!is_directory(path)) { BOOST_THROW_EXCEPTION(ErrorException{U("path should be a directory")}); } if (_cts.get_token().is_canceled()) { return; } if (_clearing > 0) { return; } auto name = utils::cleanUpFilename(node.name()); auto npath = path / name; auto npathExists = exists(npath); if (npathExists) { auto isDir = is_directory(npath); if (node.type() == Node::Type::file) { if (isDir) { BOOST_THROW_EXCEPTION(ErrorException{U("Cannot download file: a directory with the same name already exists.")}); } } if (node.type() != Node::Type::file && !isDir) { BOOST_THROW_EXCEPTION(ErrorException{U("Cannot create directory: a file with the same name already exists.")}); } } if (node.type() == Node::Type::file) { auto fdownloader = std::make_shared<FileDownloader>(path.native(), node, *_app, pplx::cancellation_token_source{}, FileDownloader::Policy::overrideNewerSize); { std::lock_guard<std::mutex> l{_mut}; fdownloader->limitRate(_rate); fdownloader->start(); if (_isPaused) { fdownloader->pause(); } } auto task = fdownloader->task(); { std::lock_guard<std::mutex> l{_mut}; _downloading = std::move(fdownloader); _progressCallback(*_downloading, _progress); } auto result = task.get(); { std::lock_guard<std::mutex> l{_mut}; _progress.fileDone += 1; _progress.bytesTransfered += node.size(); _onFileDownloadedFct(node, result.path, result.action); } } else if (!npathExists) { create_directory(npath); } // recursion for(auto& child : node.getChildren()) { downloadNode(*child, npath); } }
int main(int argc, char **argv) { if ( argc != 4 ) { fprintf(stderr, "Usage: $ ./a.out n_of_processes N write\n"); return 0; } int i, j, np = atoi(argv[1]), N = atoi(argv[2]), write = atoi(argv[3]); FILE *ff; double** a = (double**)malloc(sizeof(double*)*N); for (i = 0; i < N; ++i) { a[i] = (double*)malloc(sizeof(double)*N); } pthread_t* threads = (pthread_t*)malloc(sizeof(pthread_t)*np); // Initialization for (i = 0; i < N; ++i) { for (j = 0; j < N; ++j) { a[i][j] = 10 * i + j; } } //Prepare the tasks int buf = 0; arguments* tasks = (arguments*)malloc(sizeof(arguments)*np); for (i = 0; i < np; ++i) { tasks[i].a = a; tasks[i].start = buf; tasks[i].end = buf+task(N, np, i); tasks[i].N = N; buf += task(N, np, i); } struct timespec start, finish; double elapsed; clock_gettime(CLOCK_MONOTONIC, &start); // Parallelize for (i = 0; i < np; ++i) { if( pthread_create( threads+i, NULL, (void*(*)(void*))foo, (void*)(tasks+i)) ) { fprintf(stderr, "Failed to create a thread!\n"); exit(0); } } for (i = 0; i < np; ++i) { if( pthread_join( threads[i], NULL ) ) { fprintf(stderr, "Thread %d failed to complete!\n", i); exit(0); } } clock_gettime(CLOCK_MONOTONIC, &finish); elapsed = (finish.tv_sec - start.tv_sec); elapsed += (finish.tv_nsec - start.tv_nsec) / 1000000000.0; printf("%lf\n", elapsed); if (write) { ff = fopen("par-4.txt", "w"); for (i = 0; i < N; ++i) { for (j = 0; j < N; ++j) { fprintf(ff, "%f ", a[i][j]); } fprintf(ff, "\n"); } fclose(ff); } for (i = 0; i < N; ++i) { free(a[i]); } free(a); free(threads); free(tasks); return 0; }
jint IsolateObj::task_id( void ) const { Task::Raw t = task(); return t.not_null() ? t().task_id() : Task::INVALID_TASK_ID; }
void MainQueueAdapter::EnqueueSyncTask(const TaskFunc& func) { TaskPtr task(new Task(func), [](Task*p){delete p;}); m_queue->Enqueue(std::move(task)); m_window->SendMainMessage(m_queue); }
void ChartControl::on_paint(Canvas &canvas) { assert(glide_computer != NULL); const SETTINGS_COMPUTER &settings_computer = blackboard->SettingsComputer(); const SETTINGS_MAP &settings_map = blackboard->SettingsMap(); const MoreData &basic = blackboard->Basic(); const DerivedInfo &calculated = blackboard->Calculated(); #ifdef ENABLE_OPENGL /* enable clipping */ GLCanvasScissor scissor(canvas); #endif canvas.clear(COLOR_WHITE); canvas.set_text_color(COLOR_BLACK); canvas.select(Fonts::Map); PixelRect rcgfx = get_client_rect(); // background is painted in the base-class const FlightStatisticsRenderer fs(glide_computer->GetFlightStats(), chart_look, airspace_look, aircraft_look, task_look); switch (page) { case ANALYSIS_PAGE_BAROGRAPH: fs.RenderBarograph(canvas, rcgfx, basic, calculated, protected_task_manager); break; case ANALYSIS_PAGE_CLIMB: fs.RenderClimb(canvas, rcgfx, settings_computer.glide_polar_task); break; case ANALYSIS_PAGE_THERMAL_BAND: { OrderedTaskBehaviour otb; if (protected_task_manager != NULL) { otb = protected_task_manager->get_ordered_task_behaviour(); } ThermalBandRenderer renderer(thermal_band_look, chart_look); renderer.DrawThermalBand(basic, calculated, settings_computer, canvas, rcgfx, settings_computer.task, false, &otb); } break; case ANALYSIS_PAGE_WIND: fs.RenderWind(canvas, rcgfx, basic, glide_computer->GetWindStore()); break; case ANALYSIS_PAGE_POLAR: fs.RenderGlidePolar(canvas, rcgfx, calculated.climb_history, settings_computer, settings_computer.glide_polar_task); break; case ANALYSIS_PAGE_TEMPTRACE: fs.RenderTemperature(canvas, rcgfx); break; case ANALYSIS_PAGE_TASK: if (protected_task_manager != NULL) { const TraceComputer *trace_computer = glide_computer != NULL ? &glide_computer->GetTraceComputer() : NULL; fs.RenderTask(canvas, rcgfx, basic, calculated, settings_computer, settings_map, *protected_task_manager, trace_computer); } break; case ANALYSIS_PAGE_OLC: if (glide_computer != NULL) { TracePointVector trace; glide_computer->LockedCopyTraceTo(trace); fs.RenderOLC(canvas, rcgfx, basic, calculated, settings_computer, settings_map, calculated.contest_stats, trace); } break; case ANALYSIS_PAGE_TASK_SPEED: if (protected_task_manager != NULL) { ProtectedTaskManager::Lease task(*protected_task_manager); fs.RenderSpeed(canvas, rcgfx, basic, calculated, task); } break; default: // should never get here! break; } }
byte PaSoRi::init() { do { task(); } while (Usb.getUsbTaskState() != USB_STATE_CONFIGURING); byte rcode; //return code ep_record[0] = *( Usb.getDevTableEntry( 0,0 )); //copy endpoint 0 parameters // PASORI RC-S320 ep_record[1].epAddr = 0x01; ep_record[1].Attr = USB_TRANSFER_TYPE_INTERRUPT; ep_record[1].MaxPktSize = 0x08; ep_record[1].Interval = 0x01; ep_record[1].sndToggle = bmSNDTOG0; ep_record[1].rcvToggle = bmRCVTOG0; // PASORI RC-S330 ep_record[4].epAddr = 0x04; ep_record[4].Attr = USB_TRANSFER_TYPE_BULK; ep_record[4].MaxPktSize = 0x40; ep_record[4].Interval = 0x00; ep_record[4].sndToggle = bmSNDTOG0; ep_record[4].rcvToggle = bmRCVTOG0; Usb.setDevTableEntry( DEVADDR, ep_record ); /* read the device descriptor and check VID and PID*/ byte buf[DEV_DESCR_LEN]; rcode = Usb.getDevDescr(DEVADDR, 0, DEV_DESCR_LEN, (char*)buf); if (rcode) return rcode; #ifdef DEBUG Serial.print(buf[9], HEX); Serial.println(buf[8], HEX); Serial.print(buf[11], HEX); Serial.println(buf[10], HEX); #endif if(buf[8] != PASORI_VID_LO || buf[9] != PASORI_VID_HI) return 0xff; if (buf[10] == PASORI_PID_S320_LO && buf[11] == PASORI_PID_S320_HI) mode = PASORI_S320; else if (buf[10] == PASORI_PID_S330_LO && buf[11] == PASORI_PID_S330_HI) mode = PASORI_S330; else return 0xff; #ifdef DEBUG Serial.println(mode == PASORI_S320 ? "RC-S320 detected" : "RC-S330 detected"); #endif /* Configure device */ rcode = Usb.setConf(DEVADDR, 0, CONFVALUE); if (rcode) return rcode; Usb.setUsbTaskState(USB_STATE_RUNNING); if (mode == PASORI_S320) { if (!rcode) rcode = send_packet(sizeof(PASORI_INIT0), PASORI_INIT0); if (!rcode) rcode = send_packet(sizeof(PASORI_INIT1), PASORI_INIT1); if (!rcode) rcode = send_packet(sizeof(PASORI_INIT2), PASORI_INIT2); if (!rcode) rcode = send_packet(sizeof(PASORI_INIT3), PASORI_INIT3); if (!rcode) rcode = send_packet(sizeof(PASORI_INIT4), PASORI_INIT4); if (!rcode) rcode = send_packet(sizeof(PASORI_INIT5), PASORI_INIT5); if (!rcode) rcode = send_packet(sizeof(PASORI_READ2), PASORI_READ2); } else if (mode == PASORI_S330) { if (!rcode) rcode = send_packet(sizeof(PASORI_RF_ANTENNA_ON), PASORI_RF_ANTENNA_ON); } return rcode; }
void ParCompactionManager::push_objarray(oop obj, size_t index) { ObjArrayTask task(obj, index); assert(task.is_valid(), "bad ObjArrayTask"); _objarray_stack.push(task); }
bool preflate_decode(OutputStream& unpacked_output, std::vector<unsigned char>& preflate_diff, uint64_t& deflate_size, InputStream& deflate_raw, std::function<void(void)> block_callback, const size_t min_deflate_size, const size_t metaBlockSize) { deflate_size = 0; uint64_t deflate_bits = 0; size_t prevBitPos = 0; BitInputStream decInBits(deflate_raw); OutputCacheStream decOutCache(unpacked_output); PreflateBlockDecoder bdec(decInBits, decOutCache); if (bdec.status() != PreflateBlockDecoder::OK) { return false; } bool last; unsigned i = 0; std::vector<PreflateTokenBlock> blocks; std::vector<uint32_t> blockSizes; uint64_t sumBlockSizes = 0; uint64_t lastEndPos = 0; uint64_t uncompressedMetaStart = 0; size_t MBSize = std::min<size_t>(std::max<size_t>(metaBlockSize, 1u << 18), (1u << 31) - 1); size_t MBThreshold = (MBSize * 3) >> 1; PreflateDecoderHandler encoder(block_callback); size_t MBcount = 0; std::queue<std::future<std::shared_ptr<PreflateDecoderTask>>> futureQueue; size_t queueLimit = std::min(2 * globalTaskPool.extraThreadCount(), (1 << 26) / MBThreshold); bool fail = false; do { PreflateTokenBlock newBlock; bool ok = bdec.readBlock(newBlock, last); if (!ok) { fail = true; break; } uint64_t blockSize = decOutCache.cacheEndPos() - lastEndPos; lastEndPos = decOutCache.cacheEndPos(); if (blockSize >= (1 << 31)) { // No mega blocks fail = true; break; } blocks.push_back(newBlock); blockSizes.push_back(blockSize); ++i; block_callback(); deflate_bits += decInBits.bitPos() - prevBitPos; prevBitPos = decInBits.bitPos(); sumBlockSizes += blockSize; if (last || sumBlockSizes >= MBThreshold) { size_t blockCount, blockSizeSum; if (last) { blockCount = blockSizes.size(); blockSizeSum = sumBlockSizes; } else { blockCount = 0; blockSizeSum = 0; for (const auto bs : blockSizes) { blockSizeSum += bs; ++blockCount; if (blockSizeSum >= MBSize) { break; } } } std::vector<PreflateTokenBlock> blocksForMeta; for (size_t j = 0; j < blockCount; ++j) { blocksForMeta.push_back(std::move(blocks[j])); } blocks.erase(blocks.begin(), blocks.begin() + blockCount); blockSizes.erase(blockSizes.begin(), blockSizes.begin() + blockCount); sumBlockSizes -= blockSizeSum; size_t uncompressedOffset = MBcount == 0 ? 0 : 1 << 15; std::vector<uint8_t> uncompressedDataForMeta( decOutCache.cacheData(uncompressedMetaStart - uncompressedOffset), decOutCache.cacheData(uncompressedMetaStart - uncompressedOffset) + blockSizeSum + uncompressedOffset); uncompressedMetaStart += blockSizeSum; size_t paddingBits = 0; if (last) { uint8_t remaining_bit_count = (8 - deflate_bits) & 7; paddingBits = decInBits.get(remaining_bit_count); deflate_bits += decInBits.bitPos() - prevBitPos; prevBitPos = decInBits.bitPos(); } if (futureQueue.empty() && (queueLimit == 0 || last)) { PreflateDecoderTask task(encoder, MBcount, std::move(blocksForMeta), std::move(uncompressedDataForMeta), uncompressedOffset, last, paddingBits); if (!task.analyze() || !task.encode()) { fail = true; break; } } else { if (futureQueue.size() >= queueLimit) { std::future<std::shared_ptr<PreflateDecoderTask>> first = std::move(futureQueue.front()); futureQueue.pop(); std::shared_ptr<PreflateDecoderTask> data = first.get(); if (!data || !data->encode()) { fail = true; break; } } std::shared_ptr<PreflateDecoderTask> ptask; ptask.reset(new PreflateDecoderTask(encoder, MBcount, std::move(blocksForMeta), std::move(uncompressedDataForMeta), uncompressedOffset, last, paddingBits)); futureQueue.push(globalTaskPool.addTask([ptask,&fail]() { if (!fail && ptask->analyze()) { return ptask; } else { return std::shared_ptr<PreflateDecoderTask>(); } })); } if (!last) { decOutCache.flushUpTo(uncompressedMetaStart - (1 << 15)); } MBcount++; } } while (!fail && !last); while (!futureQueue.empty()) { std::future<std::shared_ptr<PreflateDecoderTask>> first = std::move(futureQueue.front()); futureQueue.pop(); std::shared_ptr<PreflateDecoderTask> data = first.get(); if (fail || !data || !data->encode()) { fail = true; } } decOutCache.flush(); deflate_size = (deflate_bits + 7) >> 3; if (deflate_size < min_deflate_size) { return false; } return !fail && encoder.finish(preflate_diff); }
/* Run 'task' num_tasks times serially. */ void *serial(int num_tasks) { int i; for (i = 0; i < num_tasks; i++) { task(i); } }
/** * Adds a task to execute the update function on the vertex with * the given priority. */ void add_task(vertex_id_type vertex, update_function_type update_fun, double priority = 1.0) { update_task_type task(vertex, update_fun); add_task(task, priority); }
void CDataQuotaView::HandleCommandL(TInt aCommand) { switch (aCommand) { // case EAknSoftkeyBack: // AppUi()->ProcessCommandL(EAknCmdExit); // break; case EAknCmdExit: { TApaTask task(iEikonEnv->WsSession()); task.SetWgId(CEikonEnv::Static()->RootWin().Identifier()); task.SendToBackground(); AppUi()->HandleCommandL(EAknCmdExit); } break; case EDataQuotaRefresh: { iContainer->UpdateValuesL(); iContainer->DrawNow(); #ifdef __OVI_SIGNED__ // UninstallSelfSignedVersionL(); #endif } break; case EDataQuotaEditQuota: { const TInt KMaxQuota(999999); TInt number(iContainer->DataQuota()); CAknNumberQueryDialog* dlg(CAknNumberQueryDialog::NewL(number)); dlg->PrepareLC(R_AVKON_DIALOG_QUERY_VALUE_NUMBER); dlg->SetMinimumAndMaximum(1, KMaxQuota); if (dlg->RunLD()) { iContainer->SetDataQuotaL(number); HandleCommandL(EDataQuotaRefresh); } } break; case EDataQuotaEditBillingDay: { const TInt KMinBillingDay(1); const TInt KMaxBillingDay(31); TInt number(iContainer->BillingDay() + 1); CAknNumberQueryDialog* dlg(CAknNumberQueryDialog::NewL(number)); dlg->PrepareLC(R_AVKON_DIALOG_QUERY_VALUE_NUMBER); dlg->SetMinimumAndMaximum(KMinBillingDay, KMaxBillingDay); if (dlg->RunLD()) { iContainer->SetBillingDayL(number - 1); HandleCommandL(EDataQuotaRefresh); } } break; case EDataQuotaEditDailyQuota: iContainer->SetQuotaTypeL(CDataQuotaContainer::EDaily); HandleCommandL(EDataQuotaRefresh); break; case EDataQuotaEditMonthlyQuota: iContainer->SetQuotaTypeL(CDataQuotaContainer::EMonthly); HandleCommandL(EDataQuotaRefresh); break; /* case EDataQuotaEditBillingPeriod: { TInt number(iContainer->BillingDay() + 1); TBool numberValid(EFalse); while (!numberValid) { CAknNumberQueryDialog* dlg(CAknNumberQueryDialog::NewL(number)); dlg->PrepareLC(R_AVKON_DIALOG_QUERY_VALUE_NUMBER); if (dlg->RunLD()) { if (number > 0 && number < 32) { iContainer->SetBillingDay(number - 1); numberValid = ETrue; } } else { numberValid = ETrue; } } } break; */ case EDataQuotaResetQuota: { CAknQueryDialog* dlg(CAknQueryDialog::NewL()); HBufC* text(iEikonEnv->AllocReadResourceLC( R_DATAQUOTA_RESET_QUOTA_CONFIRMATION)); if (dlg->ExecuteLD(R_DATAQUOTA_YES_NO_QUERY_DIALOG, *text)) { iContainer->ResetQuota(); HandleCommandL(EDataQuotaRefresh); } CleanupStack::PopAndDestroy(text); } break; case EDataQuotaHelp: { // Create the header text HBufC* title(iEikonEnv->AllocReadResourceLC(R_DATAQUOTA_HELP)); HBufC* help(iEikonEnv->AllocReadResourceLC(R_DATAQUOTA_HELP_TEXT)); CAknMessageQueryDialog* dlg(new(ELeave) CAknMessageQueryDialog()); // Initialise the dialog dlg->PrepareLC(R_DATAQUOTA_ABOUT_BOX); dlg->QueryHeading()->SetTextL(*title); dlg->SetMessageTextL(*help); dlg->RunLD(); CleanupStack::PopAndDestroy(2, title); // title, help } break; case EDataQuotaAbout: { // Create the header text HBufC* title1(iEikonEnv->AllocReadResourceLC(R_DATAQUOTA_ABOUT_TEXT)); HBufC* title2(KVersion().AllocLC()); HBufC* title(HBufC::NewLC(title1->Length() + title2->Length())); title->Des().Append(*title1); title->Des().Append(*title2); CAknMessageQueryDialog* dlg(new(ELeave) CAknMessageQueryDialog()); // Initialise the dialog dlg->PrepareLC(R_DATAQUOTA_ABOUT_BOX); dlg->QueryHeading()->SetTextL(*title); _LIT(KMessage, "(C) 2008-2012 Hugo van Kemenade\ncode.google.com/p/dataquota\ntwitter.com/DataQuota"); dlg->SetMessageTextL(KMessage); dlg->RunLD(); CleanupStack::PopAndDestroy(3, title1); // title1, title2, title } break; case EDataQuotaMoreAppsPodOClock: // intentional fall-through case EDataQuotaMoreAppsMobbler: // intentional fall-through case EDataQuotaMoreAppsSugarSync: // intentional fall-through { TBuf<256> url; TBool forceNativeBrowser(EFalse); switch (aCommand) { case EDataQuotaMoreAppsPodOClock: { #ifdef __OVI_SIGNED__ _LIT(KUrl, "http://store.ovi.mobi/content/180798/"); forceNativeBrowser = ETrue; #else _LIT(KUrl, "http://code.google.com/p/podoclock/"); #endif url.Copy(KUrl); } break; case EDataQuotaMoreAppsMobbler: { #ifdef __OVI_SIGNED__ _LIT(KUrl, "http://store.ovi.mobi/content/75692"); forceNativeBrowser = ETrue; #else _LIT(KUrl, "http://code.google.com/p/mobbler/"); #endif url.Copy(KUrl); } break; case EDataQuotaMoreAppsSugarSync: { _LIT(KUrl, "https://www.sugarsync.com/referral?rf=eoovtb627jrd7"); url.Copy(KUrl); } break; default: break; } OpenWebBrowserL(url, forceNativeBrowser); } break; default: break; } }
std::future<Result> operator()(Args... args) const { std::packaged_task<signature_type> task(fun); auto result = task.get_future(); std::thread(std::move(task), std::forward<Args>(args)...).detach(); // no cancellation? :( return result; }
void ClientSingleTiledLayerBuffer::PaintThebes( const nsIntRegion& aNewValidRegion, const nsIntRegion& aPaintRegion, const nsIntRegion& aDirtyRegion, LayerManager::DrawPaintedLayerCallback aCallback, void* aCallbackData, TilePaintFlags aFlags) { mWasLastPaintProgressive = !!(aFlags & TilePaintFlags::Progressive); bool asyncPaint = !!(aFlags & TilePaintFlags::Async); // Compare layer valid region size to current backbuffer size, discard if not // matching. gfx::IntSize size = aNewValidRegion.GetBounds().Size(); gfx::IntPoint origin = aNewValidRegion.GetBounds().TopLeft(); nsIntRegion paintRegion = aPaintRegion; RefPtr<TextureClient> discardedFrontBuffer = nullptr; RefPtr<TextureClient> discardedFrontBufferOnWhite = nullptr; nsIntRegion discardedValidRegion; if (mSize != size || mTilingOrigin != origin) { discardedFrontBuffer = mTile.mFrontBuffer; discardedFrontBufferOnWhite = mTile.mFrontBufferOnWhite; discardedValidRegion = mValidRegion; TILING_LOG( "TILING %p: Single-tile valid region changed. Discarding buffers.\n", &mPaintedLayer); ResetPaintedAndValidState(); mSize = size; mTilingOrigin = origin; paintRegion = aNewValidRegion; } SurfaceMode mode; gfxContentType content = GetContentType(&mode); mFormat = gfxPlatform::GetPlatform()->OptimalFormatForContent(content); if (mTile.IsPlaceholderTile()) { mTile.SetTextureAllocator(this); } if (mManager->AsShadowForwarder()->SupportsTextureDirectMapping()) { AutoTArray<uint64_t, 2> syncTextureSerials; mTile.GetSyncTextureSerials(mode, syncTextureSerials); if (syncTextureSerials.Length() > 0) { mManager->AsShadowForwarder()->SyncTextures(syncTextureSerials); } } // The dirty region relative to the top-left of the tile. nsIntRegion tileVisibleRegion = aNewValidRegion.MovedBy(-mTilingOrigin); nsIntRegion tileDirtyRegion = paintRegion.MovedBy(-mTilingOrigin); Maybe<AcquiredBackBuffer> backBuffer = mTile.AcquireBackBuffer(mCompositableClient, tileDirtyRegion, tileVisibleRegion, content, mode, aFlags); if (!backBuffer) { return; } // Mark the area we need to paint in the back buffer as invalid in the // front buffer as they will become out of sync. mTile.mInvalidFront.OrWith(tileDirtyRegion); // Add backbuffer's invalid region to the dirty region to be painted. // This will be empty if we were able to copy from the front in to the back. nsIntRegion tileInvalidRegion = mTile.mInvalidBack; tileInvalidRegion.AndWith(tileVisibleRegion); paintRegion.OrWith(tileInvalidRegion.MovedBy(mTilingOrigin)); tileDirtyRegion.OrWith(tileInvalidRegion); // Mark the region we will be painting and the region we copied from the front // buffer as needing to be uploaded to the compositor mTile.mUpdateRect = tileDirtyRegion.GetBounds().Union(backBuffer->mUpdatedRect); // If the old frontbuffer was discarded then attempt to copy what we // can from it to the new backbuffer. if (discardedFrontBuffer) { nsIntRegion copyableRegion; copyableRegion.And(aNewValidRegion, discardedValidRegion); copyableRegion.SubOut(aDirtyRegion); OpenMode readMode = asyncPaint ? OpenMode::OPEN_READ_ASYNC : OpenMode::OPEN_READ; DualTextureClientAutoLock discardedBuffer( discardedFrontBuffer, discardedFrontBufferOnWhite, readMode); if (discardedBuffer.Succeeded()) { RefPtr<gfx::SourceSurface> discardedSurface = discardedBuffer->Snapshot(); for (auto iter = copyableRegion.RectIter(); !iter.Done(); iter.Next()) { const gfx::IntRect src = iter.Get() - discardedValidRegion.GetBounds().TopLeft(); const gfx::IntPoint dest = iter.Get().TopLeft() - mTilingOrigin; backBuffer->mTarget->CopySurface(discardedSurface, src, dest); } TILING_LOG("TILING %p: Region copied from discarded frontbuffer %s\n", &mPaintedLayer, Stringify(copyableRegion).c_str()); // We don't need to repaint valid content that was just copied. paintRegion.SubOut(copyableRegion); copyableRegion.MoveBy(-mTilingOrigin); tileDirtyRegion.SubOut(copyableRegion); } else { gfxWarning() << "[Tiling:Client] Failed to aquire the discarded front " "buffer's draw target"; } } if (mode != SurfaceMode::SURFACE_OPAQUE) { for (auto iter = tileDirtyRegion.RectIter(); !iter.Done(); iter.Next()) { const gfx::Rect drawRect(iter.Get().X(), iter.Get().Y(), iter.Get().Width(), iter.Get().Height()); backBuffer->mTarget->ClearRect(drawRect); } } // Paint into the target { RefPtr<gfxContext> ctx = gfxContext::CreateOrNull(backBuffer->mTarget); if (!ctx) { gfxDevCrash(gfx::LogReason::InvalidContext) << "SingleTiledContextClient context problem " << gfx::hexa(backBuffer->mTarget); return; } ctx->SetMatrix( ctx->CurrentMatrix().PreTranslate(-mTilingOrigin.x, -mTilingOrigin.y)); aCallback(&mPaintedLayer, ctx, paintRegion, paintRegion, DrawRegionClip::DRAW, nsIntRegion(), aCallbackData); } if (asyncPaint) { if (!backBuffer->mCapture->IsEmpty()) { UniquePtr<PaintTask> task(new PaintTask()); task->mCapture = backBuffer->mCapture; task->mTarget = backBuffer->mBackBuffer; task->mClients = std::move(backBuffer->mTextureClients); if (discardedFrontBuffer) { task->mClients.AppendElement(discardedFrontBuffer); } if (discardedFrontBufferOnWhite) { task->mClients.AppendElement(discardedFrontBufferOnWhite); } // The target is an alias for the capture, and the paint thread expects // to be the only one with a reference to the capture backBuffer->mTarget = nullptr; backBuffer->mCapture = nullptr; PaintThread::Get()->QueuePaintTask(std::move(task)); mManager->SetQueuedAsyncPaints(); } } else { MOZ_ASSERT(backBuffer->mTarget == backBuffer->mBackBuffer); MOZ_ASSERT(!backBuffer->mCapture); } // The new buffer is now validated, remove the dirty region from it. mTile.mInvalidBack.SubOut(tileDirtyRegion); backBuffer = Nothing(); mTile.Flip(); UnlockTile(mTile); mValidRegion = aNewValidRegion; mLastPaintSurfaceMode = mode; mLastPaintContentType = content; }
void ThreadedTask::process() { running_ = true; task(); running_ = false; }
void LightbulbHSWidget::bringToFront() { TApaTask task( CEikonEnv::Static()->WsSession() ); task.SetWgId(CEikonEnv::Static()->RootWin().Identifier()); task.BringToForeground(); }
jint IsolateObj::exit_code( void ) const { // Always fetch the exit code from the Task, if the Task still exists // (even if it is in the STOPPING state). Task::Raw t = task(); return t.not_null() ? t().exit_code() : saved_exit_code(); }
bool TPendingTasksQ::Add(CLambda& aLambda, const TTimeDelta& aDelay) { TAutoLock lock( iLock ); TTask task(aLambda); return DoAdd(&task); }
void b3Solver::solveContactConstraintHost( b3OpenCLArray<b3RigidBodyCL>* bodyBuf, b3OpenCLArray<b3InertiaCL>* shapeBuf, b3OpenCLArray<b3GpuConstraint4>* constraint, void* additionalData, int n ,int maxNumBatches,b3AlignedObjectArray<int>* batchSizes) { #if 0 { int nSplitX = B3_SOLVER_N_SPLIT_X; int nSplitY = B3_SOLVER_N_SPLIT_Y; int numWorkgroups = B3_SOLVER_N_CELLS/B3_SOLVER_N_BATCHES; for (int z=0;z<4;z++) { for (int y=0;y<4;y++) { for (int x=0;x<4;x++) { int newIndex = (x+y*nSplitX+z*nSplitX*nSplitY); // printf("newIndex=%d\n",newIndex); int zIdx = newIndex/(nSplitX*nSplitY); int remain = newIndex%(nSplitX*nSplitY); int yIdx = remain/nSplitX; int xIdx = remain%nSplitX; // printf("newIndex=%d\n",newIndex); } } } //for (int wgIdx=numWorkgroups-1;wgIdx>=0;wgIdx--) for (int cellBatch=0;cellBatch<B3_SOLVER_N_BATCHES;cellBatch++) { for (int wgIdx=0;wgIdx<numWorkgroups;wgIdx++) { int zIdx = (wgIdx/((nSplitX*nSplitY)/4))*2+((cellBatch&4)>>2); int remain= (wgIdx%((nSplitX*nSplitY)/4)); int yIdx = (remain/(nSplitX/2))*2 + ((cellBatch&2)>>1); int xIdx = (remain%(nSplitX/2))*2 + (cellBatch&1); /*int zIdx = newIndex/(nSplitX*nSplitY); int remain = newIndex%(nSplitX*nSplitY); int yIdx = remain/nSplitX; int xIdx = remain%nSplitX; */ int cellIdx = xIdx+yIdx*nSplitX+zIdx*(nSplitX*nSplitY); // printf("wgIdx %d: xIdx=%d, yIdx=%d, zIdx=%d, cellIdx=%d, cell Batch %d\n",wgIdx,xIdx,yIdx,zIdx,cellIdx,cellBatch); } } } #endif b3AlignedObjectArray<b3RigidBodyCL> bodyNative; bodyBuf->copyToHost(bodyNative); b3AlignedObjectArray<b3InertiaCL> shapeNative; shapeBuf->copyToHost(shapeNative); b3AlignedObjectArray<b3GpuConstraint4> constraintNative; constraint->copyToHost(constraintNative); b3AlignedObjectArray<unsigned int> numConstraintsHost; m_numConstraints->copyToHost(numConstraintsHost); //printf("------------------------\n"); b3AlignedObjectArray<unsigned int> offsetsHost; m_offsets->copyToHost(offsetsHost); static int frame=0; bool useBatches=true; if (useBatches) { for(int iter=0; iter<m_nIterations; iter++) { for (int cellBatch=0;cellBatch<B3_SOLVER_N_BATCHES;cellBatch++) { int nSplitX = B3_SOLVER_N_SPLIT_X; int nSplitY = B3_SOLVER_N_SPLIT_Y; int numWorkgroups = B3_SOLVER_N_CELLS/B3_SOLVER_N_BATCHES; //printf("cell Batch %d\n",cellBatch); b3AlignedObjectArray<int> usedBodies[B3_SOLVER_N_CELLS]; for (int i=0;i<B3_SOLVER_N_CELLS;i++) { usedBodies[i].resize(0); } //for (int wgIdx=numWorkgroups-1;wgIdx>=0;wgIdx--) for (int wgIdx=0;wgIdx<numWorkgroups;wgIdx++) { int zIdx = (wgIdx/((nSplitX*nSplitY)/4))*2+((cellBatch&4)>>2); int remain= (wgIdx%((nSplitX*nSplitY)/4)); int yIdx = (remain/(nSplitX/2))*2 + ((cellBatch&2)>>1); int xIdx = (remain%(nSplitX/2))*2 + (cellBatch&1); int cellIdx = xIdx+yIdx*nSplitX+zIdx*(nSplitX*nSplitY); if( numConstraintsHost[cellIdx] == 0 ) continue; //printf("wgIdx %d: xIdx=%d, yIdx=%d, zIdx=%d, cellIdx=%d, cell Batch %d\n",wgIdx,xIdx,yIdx,zIdx,cellIdx,cellBatch); //printf("cell %d has %d constraints\n", cellIdx,numConstraintsHost[cellIdx]); if (zIdx) { //printf("?\n"); } if (iter==0) { //printf("frame=%d, Cell xIdx=%x, yIdx=%d ",frame, xIdx,yIdx); //printf("cellBatch=%d, wgIdx=%d, #constraints in cell=%d\n",cellBatch,wgIdx,numConstraintsHost[cellIdx]); } const int start = offsetsHost[cellIdx]; int numConstraintsInCell = numConstraintsHost[cellIdx]; const int end = start + numConstraintsInCell; SolveTask task( bodyNative, shapeNative, constraintNative, start, numConstraintsInCell ,maxNumBatches,usedBodies,wgIdx,batchSizes,cellIdx); task.m_solveFriction = false; task.run(0); } } } for(int iter=0; iter<m_nIterations; iter++) { for (int cellBatch=0;cellBatch<B3_SOLVER_N_BATCHES;cellBatch++) { int nSplitX = B3_SOLVER_N_SPLIT_X; int nSplitY = B3_SOLVER_N_SPLIT_Y; int numWorkgroups = B3_SOLVER_N_CELLS/B3_SOLVER_N_BATCHES; for (int wgIdx=0;wgIdx<numWorkgroups;wgIdx++) { int zIdx = (wgIdx/((nSplitX*nSplitY)/4))*2+((cellBatch&4)>>2); int remain= (wgIdx%((nSplitX*nSplitY)/4)); int yIdx = (remain/(nSplitX/2))*2 + ((cellBatch&2)>>1); int xIdx = (remain%(nSplitX/2))*2 + (cellBatch&1); int cellIdx = xIdx+yIdx*nSplitX+zIdx*(nSplitX*nSplitY); if( numConstraintsHost[cellIdx] == 0 ) continue; //printf("yIdx=%d\n",yIdx); const int start = offsetsHost[cellIdx]; int numConstraintsInCell = numConstraintsHost[cellIdx]; const int end = start + numConstraintsInCell; SolveTask task( bodyNative, shapeNative, constraintNative, start, numConstraintsInCell,maxNumBatches, 0,0,batchSizes,cellIdx); task.m_solveFriction = true; task.run(0); } } } } else { for(int iter=0; iter<m_nIterations; iter++)
void ChartControl::OnPaint(Canvas &canvas) { const ComputerSettings &settings_computer = blackboard.GetComputerSettings(); const MapSettings &settings_map = blackboard.GetMapSettings(); const MoreData &basic = blackboard.Basic(); const DerivedInfo &calculated = blackboard.Calculated(); const ProtectedTaskManager *const protected_task_manager = &glide_computer.GetProtectedTaskManager(); #ifdef ENABLE_OPENGL /* enable clipping */ GLCanvasScissor scissor(canvas); #endif canvas.Clear(COLOR_WHITE); canvas.SetTextColor(COLOR_BLACK); PixelRect rcgfx = GetClientRect(); // background is painted in the base-class switch (page) { case AnalysisPage::BAROGRAPH: RenderBarograph(canvas, rcgfx, chart_look, cross_section_look, glide_computer.GetFlightStats(), basic, calculated, protected_task_manager); break; case AnalysisPage::CLIMB: RenderClimbChart(canvas, rcgfx, chart_look, glide_computer.GetFlightStats(), settings_computer.polar.glide_polar_task); break; case AnalysisPage::THERMAL_BAND: { OrderedTaskSettings otb; if (protected_task_manager != NULL) { otb = protected_task_manager->GetOrderedTaskSettings(); } thermal_band_renderer.DrawThermalBand(basic, calculated, settings_computer, canvas, rcgfx, settings_computer.task, false, &otb); } break; case AnalysisPage::WIND: RenderWindChart(canvas, rcgfx, chart_look, glide_computer.GetFlightStats(), basic, glide_computer.GetWindStore()); break; case AnalysisPage::POLAR: RenderGlidePolar(canvas, rcgfx, chart_look, calculated.climb_history, settings_computer, settings_computer.polar.glide_polar_task); break; case AnalysisPage::TEMPTRACE: RenderTemperatureChart(canvas, rcgfx, chart_look, glide_computer.GetCuSonde()); break; case AnalysisPage::TASK: if (protected_task_manager != NULL) { const auto &trace_computer = glide_computer.GetTraceComputer(); fs_renderer.RenderTask(canvas, rcgfx, basic, settings_computer, settings_map, *protected_task_manager, &trace_computer); } break; case AnalysisPage::OLC: fs_renderer.RenderOLC(canvas, rcgfx, basic, settings_computer, settings_map, calculated.contest_stats, glide_computer.GetTraceComputer(), glide_computer.GetRetrospective()); break; case AnalysisPage::TASK_SPEED: if (protected_task_manager != NULL) { ProtectedTaskManager::Lease task(*protected_task_manager); RenderSpeed(canvas, rcgfx, chart_look, glide_computer.GetFlightStats(), basic, calculated, task); } break; case AnalysisPage::AIRSPACE: cross_section_renderer.Paint(canvas, rcgfx); break; default: // should never get here! break; } }
void MarkSweep::push_objarray(oop obj, size_t index) { ObjArrayTask task(obj, index); assert(task.is_valid(), "bad ObjArrayTask"); _objarray_stack.push(task); }
void SPUThread::start() { m_thread = std::thread([&](){ parent->setCurrentThread(this); task(); }); }
static void TestAATPoint() { OrderedTask task(task_behaviour); task.Append(StartPoint(new CylinderZone(wp1->location, 500), WaypointPtr(wp1), task_behaviour, ordered_task_settings.start_constraints)); task.Append(AATPoint(new CylinderZone(wp2->location, 10000), WaypointPtr(wp2), task_behaviour)); task.Append(FinishPoint(new CylinderZone(wp3->location, 500), WaypointPtr(wp3), task_behaviour, ordered_task_settings.finish_constraints)); task.SetActiveTaskPoint(1); task.UpdateGeometry(); ok1(task.CheckTask()); AATPoint &ap = (AATPoint &)task.GetPoint(1); ok1(!ap.IsTargetLocked()); ok1(equals(ap.GetTargetLocation(), wp2->location)); ap.LockTarget(true); ok1(ap.IsTargetLocked()); ok1(equals(ap.GetTargetLocation(), wp2->location)); GeoPoint target = MakeGeoPoint(0, 45.31); ap.SetTarget(target); ok1(ap.IsTargetLocked()); ok1(equals(ap.GetTargetLocation(), wp2->location)); ap.SetTarget(target, true); ok1(ap.IsTargetLocked()); ok1(equals(ap.GetTargetLocation(), target)); RangeAndRadial rar = ap.GetTargetRangeRadial(); ok1(equals(rar.range, 0.1112, 1000)); ok1(equals(rar.radial.Degrees(), 0, 200)); target = MakeGeoPoint(0, 45.29); ap.SetTarget(target, true); rar = ap.GetTargetRangeRadial(); ok1(equals(rar.range, -0.1112, 1000)); ok1(equals(rar.radial.Degrees(), 180, 200) || equals(rar.radial.Degrees(), -180, 200)); target = MakeGeoPoint(-0.05, 45.3); ap.SetTarget(target, true); rar = ap.GetTargetRangeRadial(); ok1(equals(rar.range, 0.39217)); ok1(equals(rar.radial.Degrees(), -89.98)); target = MakeGeoPoint(0.05, 45.3); ap.SetTarget(target, true); rar = ap.GetTargetRangeRadial(); ok1(equals(rar.range, 0.39217)); ok1(equals(rar.radial.Degrees(), 89.98)); for (int radial = -170; radial <= 170; radial += 10) { const Angle radial2 = Angle::Degrees(radial); for (int range = 10; range <= 100; range += 10) { const double range2((radial >= -90 && radial <= 90 ? range : -range) / 100.); ap.SetTarget(RangeAndRadial{range2, radial2}, task.GetTaskProjection()); rar = ap.GetTargetRangeRadial(); ok1(equals(rar.range, range2, 100)); ok1(equals(rar.radial.Degrees(), radial2.Degrees(), 100)); } } }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { // Initialize DomainParticipantFactory DDS::DomainParticipantFactory_var dpf = TheParticipantFactoryWithArgs(argc, argv); std::string participant_id; std::vector<std::string> readers; std::vector<std::string> writers; bool reliable = false; int total_readers = 0, total_writers = 0; { // New scope. ACE_Arg_Shifter shifter (argc, argv); while (shifter.is_anything_left ()) { const ACE_TCHAR* x; x = shifter.get_the_parameter (ACE_TEXT("-participant")); if (x != NULL) { participant_id = ACE_TEXT_ALWAYS_CHAR(x); } x = shifter.get_the_parameter (ACE_TEXT("-reader")); if (x != NULL) { readers.push_back(ACE_TEXT_ALWAYS_CHAR(x)); } x = shifter.get_the_parameter (ACE_TEXT("-writer")); if (x != NULL) { writers.push_back(ACE_TEXT_ALWAYS_CHAR(x)); } x = shifter.get_the_parameter (ACE_TEXT("-reliable")); if (x != NULL) { reliable = ACE_OS::atoi(x); } x = shifter.get_the_parameter (ACE_TEXT("-total_readers")); if (x != NULL) { total_readers = ACE_OS::atoi(x); } x = shifter.get_the_parameter (ACE_TEXT("-total_writers")); if (x != NULL) { total_writers = ACE_OS::atoi(x); } shifter.consume_arg (); } } participant_id.resize(12); // Create DomainParticipant DDS::DomainParticipantQos dp_qos; dpf->get_default_participant_qos(dp_qos); dp_qos.user_data.value.length(6); dp_qos.user_data.value[0] = fromhex(participant_id, 0); dp_qos.user_data.value[1] = fromhex(participant_id, 1); dp_qos.user_data.value[2] = fromhex(participant_id, 2); dp_qos.user_data.value[3] = fromhex(participant_id, 3); dp_qos.user_data.value[4] = fromhex(participant_id, 4); dp_qos.user_data.value[5] = fromhex(participant_id, 5); DDS::DomainParticipant_var participant = dpf->create_participant(DOMAIN_ID, dp_qos, 0, OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (!participant) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" create_participant failed!\n")), -1); } // Register TypeSupport TestMsgTypeSupport_var ts = new TestMsgTypeSupportImpl; if (ts->register_type(participant, "") != DDS::RETCODE_OK) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" register_type failed!\n")), -1); } // Create Topic CORBA::String_var type_name = ts->get_type_name(); DDS::Topic_var topic = participant->create_topic("TheTopic", type_name, TOPIC_QOS_DEFAULT, 0, OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (!topic) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" create_topic failed!\n")), -1); } // Create Subscriber DDS::Subscriber_var subscriber = participant->create_subscriber(SUBSCRIBER_QOS_DEFAULT, 0, OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (!subscriber) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" create_subscriber failed!\n")), -1); } const int n_msgs = reliable ? MSGS_PER_WRITER * total_writers : 0; // Create DataReaders for (std::vector<std::string>::iterator pos = readers.begin(), limit = readers.end(); pos != limit; ++pos) { pos->resize(6); DDS::DataReaderListener_var listener(new DataReaderListenerImpl(*pos, n_msgs, reader_done_callback)); DDS::DataReaderQos qos; subscriber->get_default_datareader_qos(qos); qos.user_data.value.length(3); qos.user_data.value[0] = fromhex(*pos, 0); qos.user_data.value[1] = fromhex(*pos, 1); qos.user_data.value[2] = fromhex(*pos, 2); qos.reliability.kind = reliable ? DDS::RELIABLE_RELIABILITY_QOS : DDS::BEST_EFFORT_RELIABILITY_QOS; DDS::DataReader_var reader = subscriber->create_datareader(topic, qos, listener, OpenDDS::DCPS::DEFAULT_STATUS_MASK); if (!reader) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" create_datareader failed!\n")), -1); } TestMsgDataReader_var reader_i = TestMsgDataReader::_narrow(reader); if (!reader_i) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("ERROR: %N:%l: main() -") ACE_TEXT(" _narrow failed!\n")), -1); } } WriterTask task(writers, participant, topic, reliable, total_readers); task.activate(DEFAULT_FLAGS, writers.size()); task.wait(); if (!reliable) ACE_OS::sleep(10); else { ACE_Guard<ACE_Thread_Mutex> g(readers_done_lock); while (readers_done != static_cast<int>(readers.size())) readers_done_cond.wait(); // Sleep allows an ACKNACK to be generated. ACE_OS::sleep(3); } // Clean-up! participant->delete_contained_entities(); dpf->delete_participant(participant); TheServiceParticipant->shutdown(); } catch (const CORBA::Exception& e) { e._tao_print_exception("Exception caught in main():"); return -1; } return 0; }
AppleDecoderModule::~AppleDecoderModule() { nsCOMPtr<nsIRunnable> task(new UnlinkTask()); NS_DispatchToMainThread(task); }
nsresult EMEH264Decoder::GmpInput(MP4Sample* aSample) { MOZ_ASSERT(IsOnGMPThread()); nsAutoPtr<MP4Sample> sample(aSample); if (!mGMP) { mCallback->Error(); return NS_ERROR_FAILURE; } if (sample->crypto.valid) { CDMCaps::AutoLock caps(mProxy->Capabilites()); MOZ_ASSERT(caps.CanDecryptAndDecodeVideo()); const auto& keyid = sample->crypto.key; if (!caps.IsKeyUsable(keyid)) { nsRefPtr<nsIRunnable> task(new DeliverSample(this, sample.forget())); caps.CallWhenKeyUsable(keyid, task, mGMPThread); return NS_OK; } } mLastStreamOffset = sample->byte_offset; GMPVideoFrame* ftmp = nullptr; GMPErr err = mHost->CreateFrame(kGMPEncodedVideoFrame, &ftmp); if (GMP_FAILED(err)) { mCallback->Error(); return NS_ERROR_FAILURE; } UniquePtr<gmp::GMPVideoEncodedFrameImpl> frame(static_cast<gmp::GMPVideoEncodedFrameImpl*>(ftmp)); err = frame->CreateEmptyFrame(sample->size); if (GMP_FAILED(err)) { mCallback->Error(); return NS_ERROR_FAILURE; } memcpy(frame->Buffer(), sample->data, frame->Size()); frame->SetEncodedWidth(mConfig.display_width); frame->SetEncodedHeight(mConfig.display_height); frame->SetTimeStamp(sample->composition_timestamp); frame->SetCompleteFrame(true); frame->SetDuration(sample->duration); if (sample->crypto.valid) { frame->InitCrypto(sample->crypto); } frame->SetFrameType(sample->is_sync_point ? kGMPKeyFrame : kGMPDeltaFrame); frame->SetBufferType(GMP_BufferLength32); nsTArray<uint8_t> info; // No codec specific per-frame info to pass. nsresult rv = mGMP->Decode(UniquePtr<GMPVideoEncodedFrame>(frame.release()), false, info, 0); if (NS_FAILED(rv)) { mCallback->Error(); return rv; } return NS_OK; }
/** * CreateFakeTracedTask() returns a FakeTracedTask tracking the event which is * not dispatched from its parent task directly, such as timer events. */ already_AddRefed<FakeTracedTask> CreateFakeTracedTask(int* aVptr) { nsRefPtr<FakeTracedTask> task(new FakeTracedTask(aVptr)); return task.forget(); }
void run_client(int size) { int data; MPI_Comm comm1, comm2; MPI_Status status; char port1[MPI_MAX_PORT_NAME]; char port2[MPI_MAX_PORT_NAME]; //rankprintf("opening ports.\n");fflush(stdout); MPI_Open_port(MPI_INFO_NULL, port1); MPI_Open_port(MPI_INFO_NULL, port2); //rankprintf("opened port1: <%s>\n", port1); //rankprintf("opened port2: <%s>\n", port2);fflush(stdout); MPI_Send(port1, MPI_MAX_PORT_NAME, MPI_CHAR, 1, 0, MPI_COMM_WORLD); MPI_Send(port2, MPI_MAX_PORT_NAME, MPI_CHAR, 2, 0, MPI_COMM_WORLD); //rankprintf("accepting port2.\n");fflush(stdout); MPI_Comm_accept(port2, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm2); //rankprintf("accepting port1.\n");fflush(stdout); MPI_Comm_accept(port1, MPI_INFO_NULL, 0, MPI_COMM_SELF, &comm1); MPI_Close_port(port1); MPI_Close_port(port2); MPI_Barrier(MPI_COMM_WORLD); debugMark(0); //Ping both nodes data = MSG_CHECK; MPI_Send(&data, 1, MPI_INT, 0, 0, comm1); MPI_Send(&data, 1, MPI_INT, 0, 0, comm2); sleep(1); MPI_Recv(&data, 1, MPI_INT, 0, 0, comm1, &status); if (MSG_OK != data) { sleep(3); MPI_Recv(&data, 1, MPI_INT, 0, 0, comm1, &status); } if (MSG_OK != data) { rankprintf("Rank 1 not OK\n"); } else { rankprintf("Rank 1 OK\n"); } MPI_Recv(&data, 1, MPI_INT, 0, 0, comm2, &status); if (MSG_OK != data) { sleep(3); MPI_Recv(&data, 1, MPI_INT, 0, 0, comm2, &status); } if (MSG_OK != data) { rankprintf("Rank 2 not OK\n"); } else { rankprintf("Rank 2 OK\n"); } //Create and fill two queues taskQueue q1(comm1); taskQueue q2(comm2); q1.append(task(TASK_GENVIS, 45, NPOINTS)); q1.append(task(TASK_GENIMG, 46, IMG_SIZE)); q1.append(task(TASK_DEGRID, 45, 46)); q2.append(task(TASK_GENVIS, 47, NPOINTS)); q2.append(task(TASK_GENIMG, 48, IMG_SIZE)); q2.append(task(TASK_DEGRID, 47, 48)); //Submit tasks until both queues are empty while (!(q1.empty() && q2.empty())) { if (q1.done() && !q1.empty()) q1.send_next(); if (q2.done() && !q2.empty()) q2.send_next(); sleep(1); } //Wait for final tasks to complete while (!(q1.done() && q2.done())) { sleep(1); } rankprintf("Closing\n"); //Close connections data = INT_MAX; MPI_Send(&data, 1, MPI_INT, 0, 0, comm1); MPI_Send(&data, 1, MPI_INT, 0, 0, comm2); MPI_Comm_disconnect(&comm1); MPI_Comm_disconnect(&comm2); }