virtual void SetUp() { using namespace boost::asio::ip; using boost::bind; TimedSessionBase::SetUp(); netchng = transport.install_network_handler(bind(&SessionInitiator::handle_transport_connect, this, _1, _2)); tcp::endpoint ep(address::from_string("127.0.0.1"), 9999); acceptor.open(ep.protocol()); acceptor.set_option(tcp::socket::reuse_address(true)); acceptor.bind(ep); acceptor.listen(1); acceptor.async_accept(socket, bind(&SessionInitiator::handle_transport_service_connect, this, boost::asio::placeholders::error)); transport.set_endpoint(ep); ASSERT_NO_THROW(run_event_loop_until_connect()); ASSERT_TRUE(socket.is_open()); // wait for the greeting message EXPECT_NO_THROW(run_event_loop_until_frame_received()); }
Error initialize() { if (!session::options().verifyInstallation()) { // capture standard streams Error error = initializeOutputCapture(); if (error) return error; } // subscribe to events using boost::bind; using namespace module_context; events().onClientInit.connect(bind(onClientInit)); events().onDetectChanges.connect(bind(onDetectChanges, _1)); // more initialization using boost::bind; ExecBlock initBlock ; initBlock.addFunctions() (bind(sourceModuleRFile, "SessionConsole.R")) (bind(registerRpcMethod, "reset_console_actions", resetConsoleActions)); return initBlock.execute(); }
void Button::setCurrentPosition (Position currentPosition) { lock_guard<mutex> lock (_mutex); if (currentPosition == _currentPosition) { return; } _currentPosition = currentPosition; ptime tNow = microsec_clock::local_time(); time_duration timeSinceLastCall = tNow - _positionUpdateTime; if (timeSinceLastCall < _samplingCycle) { time_duration timeToWait = _samplingCycle - timeSinceLastCall; _samplingTimer.expires_from_now (timeToWait); _samplingTimer.async_wait(bind(&Button::handleSampling, this, error)); } else { _position = _currentPosition; if (_position == Position::PRESSED) { for (IListener* listener : _listeners) { listener->buttonPressed (*this); } _buttonPressedDuration = milliseconds(0); _buttonPressedCheckTimer.expires_from_now(_checkButtonPressedCycle); _buttonPressedCheckTimer.async_wait( bind(&Button::handleButtonPressed, this, error)); } else { time_duration pressTime = tNow - _positionUpdateTime; for (IListener* listener : _listeners) { listener->buttonReleased (*this, pressTime); } } _positionUpdateTime = tNow; } }
virtual void SetUp() { using namespace boost::asio; using boost::bind; TimedSessionBase::SetUp(); session_channel = 0; user_message = beep::message(); netchng = transport.install_network_handler(bind(&SessionListener::handle_transport_connect, this, _1, _2)); listener.install_profile("casimiro.daniel/test-profile", bind(&SessionListener::handle_test_profile_change, this, _1, _2, _3, _4)); ip::tcp::endpoint ep(ip::address::from_string("127.0.0.1"), 9999); transport.set_endpoint(ep); transport.start_listening(); socket.async_connect(ep, bind(&SessionListener::handle_connect, this, placeholders::error)); ASSERT_NO_THROW(run_event_loop_until_connect()); ASSERT_TRUE(socket.is_open()); // wait for the greeting message ASSERT_NO_THROW(run_event_loop_until_frame_received()); }
void ClangCompleter::CreateClangTask( std::string filename, int line, int column, std::vector< UnsavedFile > unsaved_files, std::vector< std::string > flags ) { latest_clang_results_.ResetWithNewLineAndColumn( line, column ); function< CompletionDatas() > candidates_for_location_functor = bind( &ClangCompleter::CandidatesForLocationInFile, boost::ref( *this ), boost::move( filename ), line, column, boost::move( unsaved_files ), boost::move( flags ) ); shared_ptr< ClangPackagedTask > clang_packaged_task = make_shared< ClangPackagedTask >(); clang_packaged_task->completions_task_ = packaged_task< AsyncCompletions >( bind( ReturnValueAsShared< std::vector< CompletionData > >, candidates_for_location_functor ) ); clang_task_.Set( clang_packaged_task ); }
Error initialize() { // register postback handler for sumatra pdf #ifdef _WIN32 std::string ignoredCommand; // assumes bash script invocation, we // don't/can't use that for rsinverse Error error = module_context::registerPostbackHandler("rsinverse", rsinversePostback, &ignoredCommand); if (error) return error ; #endif // install rpc methods using boost::bind; using namespace module_context; ExecBlock initBlock ; initBlock.addFunctions() (bind(registerRpcMethod, "apply_forward_concordance", rpcApplyForwardConcordance)) (bind(registerRpcMethod, "apply_inverse_concordance", rpcApplyInverseConcordance)) (bind(registerRpcMethod, "synctex_forward_search", synctexForwardSearch)) (bind(registerRpcMethod, "synctex_inverse_search", synctexInverseSearch)) ; return initBlock.execute(); }
void traversal_algorithm::failed(node_id const& id) { m_invoke_count--; std::vector<result>::iterator i = std::find_if( m_results.begin() , m_results.end() , bind( std::equal_to<node_id>() , bind(&result::id, _1) , id ) ); assert(i != m_results.end()); assert(i->flags & result::queried); m_failed.insert(i->addr); #ifdef TORRENT_DHT_VERBOSE_LOGGING TORRENT_LOG(traversal) << "failed: " << i->id << " " << i->addr; #endif m_results.erase(i); m_table.node_failed(id); add_requests(); if (m_invoke_count == 0) done(); }
SimulationBar::SimulationBar() : ToolBar(N_("SimulationBar")) { using boost::bind; setVisibleByDefault(true); addButton(QIcon(":/Body/icons/store-world-initial.png"), _("Store body positions to the initial world state"))-> sigClicked().connect(bind(&SimulationBar::onStoreInitialClicked, this)); addButton(QIcon(":/Body/icons/restore-world-initial.png"), _("Restore body positions from the initial world state"))-> sigClicked().connect(bind(&SimulationBar::onRestoreInitialClicked, this)); typedef boost::function<void(SimulatorItem* simulator)> Callback; addButton(QIcon(":/Body/icons/start-simulation.png"), _("Start simulation from the beginning"))-> sigClicked().connect(bind(&SimulationBar::startSimulation, this, true)); addButton(QIcon(":/Body/icons/restart-simulation.png"), _("Start simulation from the current state"))-> sigClicked().connect(bind(&SimulationBar::startSimulation, this, false)); addButton(QIcon(":/Body/icons/stop-simulation.png"), _("Stop simulation"))-> sigClicked().connect(bind(&SimulationBar::onStopSimulationClicked, this)); }
////////////////////////////////////////////////////////////////////////////// /// @brief /// Returns if the string can be matched to an expression /// /// @param input The string to be matched to a regex /// @param expression The regex expression /// /// @return bool ////////////////////////////////////////////////////////////////////////////// bool Selector::check_in_selection( const std::string & input ) { // The function pointer type of the overloaded match_regex we will use // for matching. typedef bool (*Regex_match_ptr)( const string &, const regex &, match_flag_type); // Set match flag to full match or partial match, whatever was selected. match_flag_type match_type = match_default; if ( !is_and_match ) { // Check regex_match(input, ith expression, match_type) matches any // of the expressions in selection list. We must cast regex_match to the // overloaded function pointer type we are using. return ( find_if( regex_selections.begin(), regex_selections.end(), bind( static_cast<Regex_match_ptr>( regex_match ), input, _1, match_type ) ) != regex_selections.end() ); } else { return ( count_if( regex_selections.begin(), regex_selections.end(), bind( static_cast<Regex_match_ptr>( regex_match ), input, _1, match_type ) ) == regex_selections.size() ); } } // End of Selector::check_in_selection( ... )
Error completeEmbeddedRInitialization(bool useInternet2) { // set memory limit setMemoryLimit(); // use IE proxy settings if requested boost::format fmt("suppressWarnings(utils::setInternet2(%1%))"); Error error = r::exec::executeString(boost::str(fmt % useInternet2)); if (error) LOG_ERROR(error); using boost::bind; using namespace r::function_hook ; ExecBlock block ; block.addFunctions() (bind(registerUnsupported, "loadhistory", "utils")) (bind(registerUnsupported, "savehistory", "utils")) (bind(registerUnsupported, "history", "utils")) (bind(registerUnsupported, "timestamp", "utils")) (bind(registerUnsupported, "winMenuAdd", "utils")) (bind(registerUnsupported, "winMenuAddItem", "utils")) (bind(registerUnsupported, "winMenuDel", "utils")) (bind(registerUnsupported, "winMenuDelItem", "utils")) (bind(registerUnsupported, "winMenuNames", "utils")) (bind(registerUnsupported, "winMenuItems", "utils")); return block.execute(); }
void traversal_algorithm::add_requests() { while (m_invoke_count < m_branch_factor) { // Find the first node that hasn't already been queried. // TODO: Better heuristic std::vector<result>::iterator i = std::find_if( m_results.begin() , last_iterator() , bind( &bitwise_nand , bind(&result::flags, _1) , (unsigned char)result::queried ) ); #ifdef TORRENT_DHT_VERBOSE_LOGGING TORRENT_LOG(traversal) << "nodes left (" << this << "): " << (last_iterator() - i); #endif if (i == last_iterator()) break; try { invoke(i->id, i->addr); ++m_invoke_count; i->flags |= result::queried; } catch (std::exception& e) {} } }
void dht_tracker::start(entry const& bootstrap) { std::vector<udp::endpoint> initial_nodes; if (bootstrap.type() == entry::dictionary_t) { try { if (entry const* nodes = bootstrap.find_key("nodes")) read_endpoint_list<udp::endpoint>(nodes, initial_nodes); } catch (std::exception&) {} } error_code ec; m_timer.expires_from_now(seconds(1), ec); m_timer.async_wait(bind(&dht_tracker::tick, self(), _1)); m_connection_timer.expires_from_now(seconds(10), ec); m_connection_timer.async_wait( bind(&dht_tracker::connection_timeout, self(), _1)); m_refresh_timer.expires_from_now(seconds(5), ec); m_refresh_timer.async_wait(bind(&dht_tracker::refresh_timeout, self(), _1)); m_dht.bootstrap(initial_nodes, boost::bind(&dht_tracker::on_bootstrap, self())); }
UserData ClientServiceImpl::getLoggedInUser() const{ ScopeGuard fbCritSectGuard( bind(&CComCriticalSection::Lock, ref(facebookDataCritSect)), bind(&CComCriticalSection::Unlock, ref(facebookDataCritSect))); return _currentData.getLoggedInUser(); }
// Copy-ctor for unique_future is private in C++03 mode so we need to take it as // an out param void ClangCompleter::CreateSortingTask( const std::string &query, unique_future< AsyncCompletions > &future ) { // Careful! The code in this function may burn your eyes. function< CompletionDatas( const CompletionDatas & ) > sort_candidates_for_query_functor = bind( &ClangCompleter::SortCandidatesForQuery, boost::ref( *this ), query, _1 ); function< CompletionDatas() > operate_on_completion_data_functor = bind( &ClangResultsCache::OperateOnCompletionDatas< CompletionDatas >, boost::cref( latest_clang_results_ ), boost::move( sort_candidates_for_query_functor ) ); shared_ptr< packaged_task< AsyncCompletions > > task = make_shared< packaged_task< AsyncCompletions > >( bind( ReturnValueAsShared< std::vector< CompletionData > >, boost::move( operate_on_completion_data_functor ) ) ); future = task->get_future(); sorting_task_.Set( task ); }
void upnp::update_map(rootdevice& d, int i) { TORRENT_ASSERT(d.magic == 1337); TORRENT_ASSERT(i < int(d.mapping.size())); TORRENT_ASSERT(d.mapping.size() == m_mappings.size()); if (d.upnp_connection) return; mapping_t& m = d.mapping[i]; if (m.action == mapping_t::action_none || m.protocol == none) { char msg[200]; snprintf(msg, sizeof(msg), "mapping %u does not need updating, skipping", i); log(msg); m.action = mapping_t::action_none; next(d, i); return; } TORRENT_ASSERT(!d.upnp_connection); TORRENT_ASSERT(d.service_namespace); char msg[200]; snprintf(msg, sizeof(msg), "connecting to %s", d.hostname.c_str()); log(msg); if (m.action == mapping_t::action_add) { if (m.failcount > 5) { m.action = mapping_t::action_none; // giving up next(d, i); return; } if (d.upnp_connection) d.upnp_connection->close(); d.upnp_connection.reset(new http_connection(m_io_service , m_cc, bind(&upnp::on_upnp_map_response, self(), _1, _2 , boost::ref(d), i, _5), true , bind(&upnp::create_port_mapping, self(), _1, boost::ref(d), i))); d.upnp_connection->start(d.hostname, to_string(d.port).elems , seconds(10), 1); } else if (m.action == mapping_t::action_delete) { if (d.upnp_connection) d.upnp_connection->close(); d.upnp_connection.reset(new http_connection(m_io_service , m_cc, bind(&upnp::on_upnp_unmap_response, self(), _1, _2 , boost::ref(d), i, _5), true , bind(&upnp::delete_port_mapping, self(), boost::ref(d), i))); d.upnp_connection->start(d.hostname, to_string(d.port).elems , seconds(10), 1); } m.action = mapping_t::action_none; }
size_t ClientServiceImpl::getGroupsInvsCount() const{ ScopeGuard fbCritSectGuard( bind(&CComCriticalSection::Lock, ref(facebookDataCritSect)), bind(&CComCriticalSection::Unlock, ref(facebookDataCritSect))); NotificationsData nftnDta = _currentData.getNotificationsData(); return nftnDta.getGroupsInvsCount(); }
void create_torrent::add_tracker(std::string const& url, int tier) { m_urls.push_back(announce_entry(url, tier)); using boost::bind; std::sort(m_urls.begin(), m_urls.end() , bind(&announce_entry::second, _1) < bind(&announce_entry::second, _2)); }
size_t ClientServiceImpl::getPokesCount() const{ // lock on construction, unlock on destruction ScopeGuard fbCritSectGuard( bind(&CComCriticalSection::Lock, ref(facebookDataCritSect)), bind(&CComCriticalSection::Unlock, ref(facebookDataCritSect))); NotificationsData nftnDta = _currentData.getNotificationsData(); return nftnDta.getPokesCount(); }
Error initialize() { using boost::bind; using namespace session::module_context; ExecBlock initBlock ; initBlock.addFunctions() (bind(registerUriHandler, "/content", handleContentRequest)) (bind(registerRpcMethod, "remove_content_url", removeContentUrl)); return initBlock.execute(); }
void ClientServiceImpl::cleanUpCollectedData() { ScopeGuard fbCritSectGuard( bind(&CComCriticalSection::Lock, ref(facebookDataCritSect)), bind(&CComCriticalSection::Unlock, ref(facebookDataCritSect))); _toolbarNotifications.clear(); _friendsChangesPopupNotifications.clear(); _albumsChanges.clear(); _popupSelfNotifications.clear(); ServiceData emptyData; _currentData = emptyData; }
Error initialize() { // install rpc methods using boost::bind; using namespace module_context; ExecBlock initBlock ; initBlock.addFunctions() (bind(registerUriHandler, "/view_pdf", handleViewPdf)) (bind(registerUriHandler, kPdfJsPath, handlePdfJs)) ; return initBlock.execute(); }
Error initialize() { using boost::bind; using namespace session::module_context; ExecBlock initBlock ; initBlock.addFunctions() (data::viewer::initialize) (bind(sourceModuleRFile, "SessionDataImport.R")) (bind(sourceModuleRFile, "SessionDataImportV2.R")); return initBlock.execute(); }
Error initialize() { using boost::bind; using namespace module_context; ExecBlock initBlock ; initBlock.addFunctions() (bind(registerRpcMethod, "accept_agreement", handleAcceptAgreement)) (bind(registerUriHandler, "/agreement", handleAgreementRequest)) ; return initBlock.execute(); }
OD grammar_args::options() { namespace po = boost::program_options; using std::string; using boost::bind; using boost::ref; using namespace graehl; OD od("grammar options"); od.add_options() ("grammar-archive,g", defaulted_value(&grammar_archive), "archived translation rules grammar") ( "grammar-format,f" , defaulted_value(&grammar_format), "legal values: brf, archive(default), fat-archive, " "text-archive, fat-text-archive" ) ("weight-file,w" ,po::value<string>()->notifier(bind(&weights_from_file,ref(*this),_1)) ,"file with feature and lm exponents (weights), " "single or multiple lines of: a:-1,b:2.5") ("weight-string" ,po::value<string>()->notifier(bind(&weights_from_string,ref(*this),_1)) ,"same format as weights file; completely overrides any --weight-file") ("verbose-non-numeric", defaulted_value(&verbose), "complain to STDERR about nonnumeric rule attributes") ("final-weights-to", defaulted_value(&final_weights_to), "print weights finally used here (same format as weight-string/file)") ; OD prior_opts("Heuristic (English) per-tag prior probability options"); prior_opts.add_options() ("prior-file", defaulted_value(&prior_file), "file with alternating <tag> <count> e.g. NP 123478. virtual tags ignored") ("prior-floor-prob", defaulted_value(&prior_floor_prob), "minimum probability for missing or low-count tags") ("prior-bonus-count", defaulted_value(&prior_bonus_count), "give every tag that appears in prior-file this many extra counts (before normalization)") ("weight-prior", defaulted_value(&weight_tag_prior), "raise prior prob to this power for rule heuristic") ("tag-prior-bonus", defaulted_value(&grammar.tag_prior_bonus), "constant prior multiplied into (nonvirtual) tag heuristic. greater than 1 <=> favor tags more than virtuals") ; od.add(prior_opts); OD feature_opts("(nonnumeric) feature options"); feature_opts.add_options() ("keep-text-features",defaulted_value(&keep_texts), "Keep the unused nonnumeric features in memory") ("keep-align",defaulted_value(&keep_align), "parse the 'align' attribute for word/variable alignments") ; od.add(feature_opts); return od; }
Error initialize() { // install rpc methods using boost::bind; using namespace module_context; ExecBlock initBlock ; initBlock.addFunctions() (tex::compile_pdf::initialize) (bind(registerRpcMethod, "is_tex_installed", isTexInstalled)) (bind(registerRpcMethod, "get_tex_capabilities", getTexCapabilities)) ; return initBlock.execute(); }
Error initialize() { // install rpc methods using boost::bind; using namespace module_context; ExecBlock initBlock ; initBlock.addFunctions() (bind(registerRpcMethod, "process_prepare", procInit)) (bind(registerRpcMethod, "process_start", procStart)) (bind(registerRpcMethod, "process_interrupt", procInterrupt)); return initBlock.execute(); }
Error initialize() { // add suspend handler using namespace session::module_context; addSuspendHandler(SuspendHandler(onSuspend, onResume)); // subscribe to events using boost::bind; events().onClientInit.connect(bind(onClientInit)); events().onDetectChanges.connect(bind(onDetectChanges, _1)); return Success(); }
Error initialize() { // subscribe to events using boost::bind; using namespace module_context; ExecBlock initBlock ; initBlock.addFunctions() (bind(registerRpcMethod, "get_function_state", getFunctionState)) (bind(registerRpcMethod, "set_function_breakpoints", setBreakpoints)) (bind(sourceModuleRFile, "SessionBreakpoints.R")); return initBlock.execute(); }
Error initialize() { // subscribe to events using boost::bind; using namespace module_context; events().onPackageLoaded.connect(onPackageLoaded); ExecBlock initBlock ; initBlock.addFunctions() (bind(registerRpcMethod, "get_function_sync_state", getFunctionSyncState)) (bind(sourceModuleRFile, "SessionBreakpoints.R")); return initBlock.execute(); }
core::Error initialize() { using namespace module_context; using boost::bind; events().afterSessionInitHook.connect(afterSessionInitHook); events().onClientInit.connect(onClientInit); ExecBlock initBlock; initBlock.addFunctions() (bind(registerRpcMethod, "save_snippets", saveSnippets)) (bind(registerRpcMethod, "get_snippets", getSnippets)); return initBlock.execute(); }