void Library::synchronize() const { if (myScanSubdirs != ScanSubdirsOption.value() || myPath != PathOption.value()) { std::vector<std::string> oldPathes; ZLStringUtil::split(myPath, oldPathes, ZLibrary::PathDelimiter); for (size_t i = 0; i < oldPathes.size(); ++i) { ZLFSWatcher::removeWatcher(oldPathes.at(i), myWatcher); } myPath = PathOption.value(); myScanSubdirs = ScanSubdirsOption.value(); std::vector<std::string> pathes; ZLStringUtil::split(myPath, pathes, ZLibrary::PathDelimiter); for (size_t i = 0; i < pathes.size(); ++i) { ZLFSWatcher::addWatcher(pathes.at(i), myWatcher); } myBuildMode = BUILD_ALL; } if (myBuildMode == BUILD_NOTHING) { return; } LibrarySynchronizer synchronizer(myBuildMode); myBuildMode = BUILD_NOTHING; ZLDialogManager::Instance().wait(ZLResourceKey("loadingBookList"), synchronizer); ++myRevision; }
void TestDocumentFileWriteJob::startWriteToFile() { TestDocumentFileSynchronizer* testSynchronizer = qobject_cast<TestDocumentFileSynchronizer*>( synchronizer() ); TestDocument* document = qobject_cast<TestDocument*>( synchronizer()->document() ); TestDocumentFileWriteThread* writeThread = new TestDocumentFileWriteThread( this, testSynchronizer->header(), document, file() ); writeThread->start(); while( !writeThread->wait(100) ) QApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers, 100 ); const bool success = writeThread->success(); delete writeThread; completeWrite( success ); }
void ByteArrayRawFileWriteJob::startWriteToFile() { ByteArrayDocument *document = qobject_cast<ByteArrayDocument*>( synchronizer()->document() ); ByteArrayRawFileWriteThread* writeThread = new ByteArrayRawFileWriteThread( this, document, file() ); writeThread->start(); while( !writeThread->wait(100) ) QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers, 100 ); const bool success = writeThread->success(); delete writeThread; // if( success ) // ExternalBookmarkStorage().writeBookmarks( document, synchronizer()->url() ); completeWrite( success ); }
int main(int argc, char** argv ) { ros::init(argc, argv, "disp_map"); ros::NodeHandle nh; message_filters::Subscriber<sensor_msgs::Image> leftImageSub(nh, "/wide_stereo/left/image_raw", 1); message_filters::Subscriber<sensor_msgs::CameraInfo> leftCameraInfoSub(nh, "/wide_stereo/left/camera_info", 1); message_filters::Subscriber<sensor_msgs::Image> rightImageSub(nh, "/wide_stereo/right/image_raw", 1); message_filters::Subscriber<sensor_msgs::CameraInfo> rightCameraInfoSub(nh, "/wide_stereo/right/camera_info", 1); message_filters::Subscriber<sensor_msgs::Image> depthMapSub(nh, "/camera/depth/image_raw", 1); initSGBM(); typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::Image, sensor_msgs::CameraInfo, sensor_msgs::CameraInfo> syncPolicy; message_filters::Synchronizer<syncPolicy> synchronizer(syncPolicy(10), leftImageSub, rightImageSub, depthMapSub, leftCameraInfoSub, rightCameraInfoSub); //first callback must execute before second - it is very important synchronizer.registerCallback(boost::bind(&cameraInfoHandler, _1, _2, _3, _4, _5)); synchronizer.registerCallback(boost::bind(&picHandler, _1, _2, _3, _4, _5)); ros::spin(); //should execute after we read all messages //theese formulaes are recursive so we can avoid overflow long double mean = 0; for (size_t i = 0; i < xs.size(); ++i) { mean = ((mean * i) + xs[i])/(i + 1); } long double sd = 0; for (size_t i = 0; i < xs.size(); ++i) { sd = sqrt( ((sqr(sd) * i) + sqr(xs[i] - mean))/(i + 1) ); } printf("Mean is: %Lf\n", mean); printf("Standard deviation is: %Lf\n", sd); return 0; }
void Library::synchronize() const { if (myScanSubdirs != ScanSubdirsOption.value() || myPath != PathOption.value()) { myPath = PathOption.value(); myScanSubdirs = ScanSubdirsOption.value(); myBuildMode = BUILD_ALL; } if (myBuildMode == BUILD_NOTHING) { return; } LibrarySynchronizer synchronizer(myBuildMode); myBuildMode = BUILD_NOTHING; ZLDialogManager::Instance().wait(ZLResourceKey("loadingBookList"), synchronizer); ++myRevision; }
int main(int argc, char ** argv) { CContext context(argc, argv); if (context._options == nullptr) return EXIT_FAILURE; if (!context.getCredentials()) return EXIT_FAILURE; CRemoteLs remoteLs( context ); CMySourceParser srcParser(context); // fill local and remote queues CLocalMd5Process md5LocalEngine(context); // consume local queue and feed localDone queue CBackupStatusUpdater bStatusUpdater( context, remoteLs); // consume localMd5Done and feed todo queue remoteLs.start(); srcParser.start(); md5LocalEngine.start(numThread_localMd5); remoteLs.waitForDone(); CRemoteMd5Process md5RemoteEngine(context, remoteLs); // consume remote queue and feed remoteDone queue md5RemoteEngine.start(numThread_remoteMd5); bStatusUpdater.start(); CSynchronizer synchronizer(context); CBackupDeleter deleter(context, srcParser, remoteLs); synchronizer.start(); srcParser.waitDone(); // here we can check for destinations files to be deleted deleter.start(); /* // don't need to call these because // they are automatacally called // on their destructors md5LocalEngine.waitDone(); md5RemoteEngine.waitDone(); synchronizer.waitDone(); deleter.waitDone(); */ return EXIT_SUCCESS; }
void TestDocumentFileLoadJob::startLoadFromFile() { TestDocumentFileSynchronizer* testSynchronizer = qobject_cast<TestDocumentFileSynchronizer*>( synchronizer() ); TestDocumentFileLoadThread* loadThread = new TestDocumentFileLoadThread( this, testSynchronizer->header(), file() ); loadThread->start(); while( !loadThread->wait(100) ) QApplication::processEvents( QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers, 100 ); TestDocument* document = loadThread->document(); testSynchronizer->setDocument( document ); delete loadThread; setDocument( document ); }