Proxy( eq::Channel* ch ) : _stream( 0 ) , _eventHandler( 0 ) , _channel( ch ) , _sendFuture( make_ready_future( false )) , _running( false ) , _texture( 0 ) { const DrawableConfig& dc = _channel->getDrawableConfig(); if( dc.colorBits != 8 ) { LBWARN << "Can only stream 8-bit RGB(A) framebuffers to " << "DisplayCluster, got " << dc.colorBits << " color bits" << std::endl; return; } const std::string& dcHost = _channel->getView()->getDisplayCluster(); _stream = new ::dc::Stream( _channel->getView()->getName(), dcHost ); if( !_stream->isConnected( )) { LBWARN << "Could not connect to DisplayCluster host: " << dcHost << std::endl; return; } _running = true; _sendFuture = make_ready_future( true ); }
void unpin() { // make sure to always grab to AGAS lock first agas::mark_as_migrated(this->gid_, [this]() mutable -> std::pair<bool, hpx::future<void> > { std::unique_lock<mutex_type> l(mtx_); HPX_ASSERT(this->pin_count_ != 0); if (this->pin_count_ != ~0x0u) { if (--this->pin_count_ == 0) { // trigger pending migration if this was the last // unpin and a migration operation is pending if (trigger_migration_.valid() && was_marked_for_migration_) { was_marked_for_migration_ = false; l.unlock(); trigger_migration_.set_value(); return std::make_pair(true, make_ready_future()); } } } return std::make_pair(false, make_ready_future()); }); }
int main() { auto a = make_ready_future(get_name()); // ok auto b = make_ready_future(get_name("Sir")); // ok std::future<std::string> c = make_ready_future(get_name("Sir")); // ok std::future<std::string> d = make_ready_future(get_name()); // error: return type mismatch from std::future<std::string&> }
future<id_type> migrate_component( id_type const& to_migrate, naming::address const& addr, DistPolicy const& policy) { // 'migration' to same locality as before is a no-op if (policy.get_next_target() == hpx::find_here()) { return make_ready_future(to_migrate); } if (!traits::component_supports_migration<Component>::call()) { return hpx::make_exceptional_future<hpx::id_type>( HPX_GET_EXCEPTION(invalid_status, "hpx::components::server::migrate_component", "attempting to migrate an instance of a component which " "does not support migration")); } // retrieve pointer to object (must be local) std::shared_ptr<Component> ptr = hpx::detail::get_ptr_for_migration<Component>(addr, to_migrate); // perform actual migration by sending data over to target locality return detail::migrate_component_postproc<Component>( ptr, to_migrate, policy); }
type operator()(future<T> const& x) const { if (auto&& state = x.get_state(use_private_interface)) return state->template then<future<void>>(std::bind([](){})); else return make_ready_future(); }
hpx::future<void> mark_as_migrated(hpx::id_type const& to_migrate) { // we need to first lock the AGAS migrated objects table, only then // access (lock) the object return agas::mark_as_migrated(to_migrate.get_gid(), [this]() mutable -> std::pair<bool, hpx::future<void> > { std::unique_lock<mutex_type> l(mtx_); // make sure that no migration is currently in flight if (was_marked_for_migration_) { l.unlock(); return std::make_pair(false, hpx::make_exceptional_future<void>( HPX_GET_EXCEPTION(invalid_status, "migration_support::mark_as_migrated", "migration operation is already in flight") )); } if (1 == pin_count_) { // all is well, migration can be triggered now return std::make_pair(true, make_ready_future()); } // delay migrate operation until pin count goes to zero was_marked_for_migration_ = true; l.unlock(); return std::make_pair(true, trigger_migration_.get_future()); }); }
std::future<bool> send(core::const_frame frame) override { CASPAR_VERIFY(format_desc_.height * format_desc_.width * 4 == frame.image_data(0).size()); graph_->set_value("tick-time", tick_timer_.elapsed() * format_desc_.fps * 0.5); tick_timer_.restart(); caspar::timer frame_timer; { auto audio_buffer = core::audio_32_to_16(frame.audio_data()); airsend::add_audio(air_send_.get(), audio_buffer.data(), static_cast<int>(audio_buffer.size()) / format_desc_.audio_channels); } { connected_ = airsend::add_frame_bgra(air_send_.get(), frame.image_data(0).begin()); } graph_->set_text(print()); graph_->set_value("frame-time", frame_timer.elapsed() * format_desc_.fps * 0.5); return make_ready_future(true); }
future<naming::id_type> trigger_migrate_to_storage_here( naming::id_type const& to_migrate, naming::id_type const& target_storage) { if (!Component::supports_migration()) { HPX_THROW_EXCEPTION(invalid_status, "hpx::components::server::trigger_migrate_to_storage_here", "attempting to migrate an instance of a component which " "does not support migration"); return make_ready_future(naming::invalid_id); } if (naming::get_locality_id_from_id(to_migrate) != get_locality_id()) { HPX_THROW_EXCEPTION(invalid_status, "hpx::components::server::trigger_migrate_to_storage_here", "this function has to be executed on the locality responsible " "for managing the address of the given object"); return make_ready_future(naming::invalid_id); } return agas::begin_migration(to_migrate, target_storage) .then( [to_migrate, target_storage]( future<std::pair<naming::id_type, naming::address> > && f) -> future<naming::id_type> { // rethrow errors std::pair<naming::id_type, naming::address> r = f.get(); // perform actual object migration typedef server::migrate_to_storage_here_action<Component> action_type; return async<action_type>(r.first, to_migrate, r.second, target_storage); }) .then( [to_migrate](future<naming::id_type> && f) -> naming::id_type { agas::end_migration(to_migrate).get(); return f.get(); }); }
future<Credentials> ContentModuleManager::RequestCredentialInput(const CredentialRequest &request) { // nothing yet... // really want the std::make_immediate_future<>() function right now... std::promise<Credentials> promise; Credentials none; return make_ready_future(none); }
future<naming::id_type> migrate_component( naming::id_type const& to_migrate, naming::id_type const& target_locality) { // 'migration' to same locality as before is a no-op if (target_locality == hpx::find_here()) { return make_ready_future(to_migrate); } if (!Component::supports_migration()) { HPX_THROW_EXCEPTION(invalid_status, "hpx::components::server::migrate_component", "attempting to migrate an instance of a component which is " "does not support migration"); return make_ready_future(naming::invalid_id); } return hpx::detail::get_ptr_for_migration<Component>(to_migrate) .then(util::bind(&detail::migrate_component_postproc<Component>, util::placeholders::_1, to_migrate, target_locality)); }
lcos::future<naming::id_type> runtime_support::create_performance_counter_async(naming::id_type targetgid, performance_counters::counter_info const& info) { if (!naming::is_locality(targetgid)) { HPX_THROW_EXCEPTION(bad_parameter, "stubs::runtime_support::create_performance_counter_async", "The id passed as the first argument is not representing" " a locality"); return make_ready_future(naming::invalid_id); } typedef server::runtime_support::create_performance_counter_action action_type; return hpx::async<action_type>(targetgid, info); }
lcos::future<std::vector<naming::id_type> > runtime_support::bulk_create_components_async( naming::id_type const& gid, components::component_type type, std::size_t count) { if (!naming::is_locality(gid)) { HPX_THROW_EXCEPTION(bad_parameter, "stubs::runtime_support::bulk_create_components_async", "The id passed as the first argument is not representing" " a locality"); return make_ready_future(std::vector<naming::id_type>()); } // Create a future, execute the required action, // we simply return the initialized future, the caller needs // to call get() on the return value to obtain the result typedef server::runtime_support::bulk_create_components_action action_type; return hpx::async<action_type>(gid, type, count); }
lcos::future<naming::id_type> runtime_support::create_memory_block_async( naming::id_type const& id, std::size_t count, hpx::actions::manage_object_action<T, Config> const& act) { if (!naming::is_locality(id)) { HPX_THROW_EXCEPTION(bad_parameter, "stubs::runtime_support::create_memory_block_async", "The id passed as the first argument is not representing" " a locality"); return make_ready_future(naming::invalid_id); } // Create a future, execute the required action, // we simply return the initialized future, the caller needs // to call get() on the return value to obtain the result typedef server::runtime_support::create_memory_block_action action_type; return hpx::async<action_type>(id, count, act); }
future<naming::id_type> migrate_to_storage_here( naming::id_type const& to_migrate, naming::address const& addr, naming::id_type const& target_storage) { if (!Component::supports_migration()) { HPX_THROW_EXCEPTION(invalid_status, "hpx::components::server::migrate_to_storage_here", "attempting to migrate an instance of a component which " "does not support migration"); return make_ready_future(naming::invalid_id); } // retrieve pointer to object (must be local) boost::shared_ptr<Component> ptr = hpx::detail::get_ptr_for_migration<Component>(addr, to_migrate); // perform actual migration by sending data over to target locality return detail::migrate_to_storage_here_postproc<Component>( ptr, to_migrate, target_storage); }
future<void> when_all_ready(ForwardIterator first, ForwardIterator last) { auto const diff = std::distance(first, last); if (diff <= 0) return make_ready_future(); typedef typename std::iterator_traits<ForwardIterator>::difference_type diff_t; auto counter = std::make_shared<std::atomic<diff_t>>(diff); auto prm = std::make_shared<promise<void>>(); auto dec = std::bind([=](){ if (counter->fetch_sub(1) == 1) prm->set_value(); }); // bind to ignore all arguments std::for_each(first, last, [=](typename std::iterator_traits<ForwardIterator>::reference f) mutable { if (!f.valid()) dec(); else f.get_state(detail::use_private_interface)->continue_with(dec); }); return prm->get_future(); }