sp<MMCameraDL> MMCameraDL::getInstance(){ Mutex::Autolock instanceLock(singletonLock); sp<MMCameraDL> mmCamera = instance.promote(); if(mmCamera == NULL){ mmCamera = new MMCameraDL(); instance = mmCamera; } return mmCamera; }
/// Run the main GUI window int main(int argc, char* argv[]) { std::string lockName; std::string lockId; std::string socketName; ArgParse::ArgParse ap; ap.options( "displaz-gui - don't use this directly, use the displaz commandline helper instead)", "-instancelock %s %s", &lockName, &lockId, "Single instance lock name and ID to reacquire", "-socketname %s", &socketName, "Local socket name for IPC", NULL ); if(ap.parse(argc, const_cast<const char**>(argv)) < 0) { std::cerr << "ERROR: " << ap.geterror() << std::endl; return EXIT_FAILURE; } QApplication app(argc, argv); QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8")); setupQFileSearchPaths(); Q_INIT_RESOURCE(resource); qRegisterMetaType<std::shared_ptr<Geometry>>("std::shared_ptr<Geometry>"); // Multisampled antialiasing - this makes rendered point clouds look much // nicer, but also makes the render much slower, especially on lower // powered graphics cards. //QGLFormat f = QGLFormat::defaultFormat(); //f.setSampleBuffers(true); //QGLFormat::setDefaultFormat(f); PointViewerMainWindow window; InterProcessLock instanceLock(lockName); if (!lockId.empty()) instanceLock.inherit(lockId); if (!socketName.empty()) window.startIpcServer(QString::fromStdString(socketName)); window.show(); return app.exec(); }
std::unique_ptr<TransferReport> Receiver::finish() { std::unique_lock<std::mutex> instanceLock(instanceManagementMutex_); TransferStatus status = getTransferStatus(); if (status == NOT_STARTED) { WLOG(WARNING) << "Even though transfer has not started, finish is called"; // getTransferReport will set the error code to ERROR return getTransferReport(); } if (status == THREADS_JOINED) { WLOG(WARNING) << "Threads have already been joined. Returning the " << "transfer report"; return getTransferReport(); } if (!isJoinable_) { // TODO: don't complain about this when coming from runForever() WLOG(WARNING) << "The receiver is not joinable. The threads will never" << " finish and this method will never return"; } for (auto &receiverThread : receiverThreads_) { receiverThread->finish(); } setTransferStatus(THREADS_JOINED); if (isJoinable_) { // Make sure to join the progress thread. progressTrackerThread_.join(); } std::unique_ptr<TransferReport> report = getTransferReport(); auto &summary = report->getSummary(); bool transferSuccess = (report->getSummary().getErrorCode() == OK); fixAndCloseTransferLog(transferSuccess); auto totalSenderBytes = summary.getTotalSenderBytes(); if (progressReporter_ && totalSenderBytes >= 0) { report->setTotalFileSize(totalSenderBytes); report->setTotalTime(durationSeconds(Clock::now() - startTime_)); progressReporter_->end(report); } logPerfStats(); WLOG(WARNING) << "WDT receiver's transfer has been finished"; WLOG(INFO) << *report; return report; }
std::unique_ptr<TransferReport> Sender::finish() { std::unique_lock<std::mutex> instanceLock(instanceManagementMutex_); VLOG(1) << "Sender::finish()"; TransferStatus status = getTransferStatus(); if (status == NOT_STARTED) { LOG(WARNING) << "Even though transfer has not started, finish is called"; // getTransferReport will set the error code to ERROR return getTransferReport(); } if (status == THREADS_JOINED) { VLOG(1) << "Threads have already been joined. Returning the" << " existing transfer report"; return getTransferReport(); } const bool twoPhases = options_.two_phases; bool progressReportEnabled = progressReporter_ && progressReportIntervalMillis_ > 0; for (auto &senderThread : senderThreads_) { senderThread->finish(); } if (!twoPhases) { dirThread_.join(); } WDT_CHECK(numActiveThreads_ == 0); setTransferStatus(THREADS_JOINED); if (progressReportEnabled) { progressReporterThread_.join(); } std::vector<TransferStats> threadStats; for (auto &senderThread : senderThreads_) { threadStats.push_back(senderThread->moveStats()); } bool allSourcesAcked = false; for (auto &senderThread : senderThreads_) { auto &stats = senderThread->getTransferStats(); if (stats.getErrorCode() == OK) { // at least one thread finished correctly // that means all transferred sources are acked allSourcesAcked = true; break; } } std::vector<TransferStats> transferredSourceStats; for (auto port : transferRequest_.ports) { auto &transferHistory = transferHistoryController_->getTransferHistory(port); if (allSourcesAcked) { transferHistory.markAllAcknowledged(); } else { transferHistory.returnUnackedSourcesToQueue(); } if (options_.full_reporting) { std::vector<TransferStats> stats = transferHistory.popAckedSourceStats(); transferredSourceStats.insert(transferredSourceStats.end(), std::make_move_iterator(stats.begin()), std::make_move_iterator(stats.end())); } } if (options_.full_reporting) { validateTransferStats(transferredSourceStats, dirQueue_->getFailedSourceStats()); } int64_t totalFileSize = dirQueue_->getTotalSize(); double totalTime = durationSeconds(endTime_ - startTime_); std::unique_ptr<TransferReport> transferReport = folly::make_unique<TransferReport>( transferredSourceStats, dirQueue_->getFailedSourceStats(), threadStats, dirQueue_->getFailedDirectories(), totalTime, totalFileSize, dirQueue_->getCount()); if (progressReportEnabled) { progressReporter_->end(transferReport); } if (options_.enable_perf_stat_collection) { PerfStatReport report(options_); for (auto &senderThread : senderThreads_) { report += senderThread->getPerfReport(); } report += dirQueue_->getPerfReport(); LOG(INFO) << report; } double directoryTime; directoryTime = dirQueue_->getDirectoryTime(); LOG(INFO) << "Total sender time = " << totalTime << " seconds (" << directoryTime << " dirTime)" << ". Transfer summary : " << *transferReport << "\nTotal sender throughput = " << transferReport->getThroughputMBps() << " Mbytes/sec (" << transferReport->getSummary().getEffectiveTotalBytes() / (totalTime - directoryTime) / kMbToB << " Mbytes/sec pure transfer rate)"; return transferReport; }
/// Run the main GUI window int main(int argc, char* argv[]) { std::string lockName; std::string lockId; std::string socketName; std::string serverName; ArgParse::ArgParse ap; ap.options( "displaz-gui - don't use this directly, use the displaz commandline helper instead)", "-instancelock %s %s", &lockName, &lockId, "Single instance lock name and ID to reacquire", "-socketname %s", &socketName, "Local socket name for IPC", "-server %s", &serverName, "DEBUG: Compute lock file and socket name; do not inherit lock", NULL ); if(ap.parse(argc, const_cast<const char**>(argv)) < 0) { std::cerr << "ERROR: " << ap.geterror() << std::endl; return EXIT_FAILURE; } QApplication app(argc, argv); #ifdef DISPLAZ_USE_QT4 // Qt5: no longer required QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8")); #endif setupQFileSearchPaths(); Q_INIT_RESOURCE(resource); qRegisterMetaType<std::shared_ptr<Geometry>>("std::shared_ptr<Geometry>"); // Multisampled antialiasing - this makes rendered point clouds look much // nicer, but also makes the render much slower, especially on lower // powered graphics cards. QGLFormat f = QGLFormat::defaultFormat(); f.setVersion( 3, 2 ); f.setProfile( QGLFormat::CoreProfile ); // Requires >=Qt-4.8.0 //f.setSampleBuffers(true); QGLFormat::setDefaultFormat(f); PointViewerMainWindow window(f); // Inherit instance lock (or debug: acquire it) if (!serverName.empty()) getDisplazIpcNames(socketName, lockName, serverName); InterProcessLock instanceLock(lockName); if (!lockId.empty()) { instanceLock.inherit(lockId); } else if (!serverName.empty()) { if (!instanceLock.tryLock()) { std::cerr << "ERROR: Another displaz instance has the lock\n"; return EXIT_FAILURE; } } if (!socketName.empty()) window.startIpcServer(QString::fromStdString(socketName)); window.show(); return app.exec(); }