• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ context_t类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中context_t的典型用法代码示例。如果您正苦于以下问题:C++ context_t类的具体用法?C++ context_t怎么用?C++ context_t使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了context_t类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: pool

pool_ptr pool(context_t& context, const std::string& name) {
    auto pool = context.config().component_group("postgres").get(name);
    if(!pool) {
        throw error_t(std::errc::argument_out_of_domain, "postgres component with name '{}' not found", name);
    }
    return context.repository().get<pool_t>("postgres", context, name, pool->args());
}
开发者ID:3Hren,项目名称:cocaine-plugins,代码行数:7,代码来源:pool.cpp


示例2: getContext

/* compute the current binary context */
void ContextTree::getContext(const history_t &h, context_t &context) const {

    context.clear();
    for (size_t i=0; i < m_depth; ++i) {
        context.push_back(h[h.size()-i-1]);
    }
}
开发者ID:floringogianu,项目名称:SkipCTS,代码行数:8,代码来源:ctw.cpp


示例3: unicorn

/**
 * Unicorn trait for service creation.
 * Trait to create unicorn service by name. All instances are cached by name as it is done in storage.
 */
unicorn_ptr
unicorn(context_t& context, const std::string& name) {
    auto unicorn = context.config().unicorns().get(name);
    if(!unicorn) {
        throw error_t(error::component_not_found, "unicorn component \"{}\" not found in the config", name);
    }
    return context.repository().get<unicorn_t>(unicorn->type(), context, name, unicorn->args());
}
开发者ID:cocaine,项目名称:cocaine-core,代码行数:12,代码来源:unicorn.cpp


示例4: metrics

actor_base<Protocol>::actor_base(context_t& context, io::dispatch_ptr_t prototype) :
    m_context(context),
    m_log(context.log("core/asio", {{"service", prototype->name()}})),
    metrics(new metrics_t{
        context.metrics_hub().counter<std::int64_t>(cocaine::format("{}.connections.accepted", prototype->name())),
        context.metrics_hub().counter<std::int64_t>(cocaine::format("{}.connections.rejected", prototype->name()))
    }),
    m_prototype(std::move(prototype))
{}
开发者ID:3Hren,项目名称:cocaine-core,代码行数:9,代码来源:actor.cpp


示例5: category_type

multicast_t::multicast_t(context_t& context, interface& locator, const std::string& name, const dynamic_t& args):
    category_type(context, locator, name, args),
    m_context(context),
    m_log(context.log(name)),
    m_locator(locator),
    m_cfg(args.to<multicast_cfg_t>()),
    m_socket(locator.asio()),
    m_timer(locator.asio())
{
    m_socket.open(m_cfg.endpoint.protocol());
    m_socket.set_option(socket_base::reuse_address(true));

    if(m_cfg.endpoint.address().is_v4()) {
        m_socket.bind(udp::endpoint(address_v4::any(), m_cfg.endpoint.port()));
    } else {
        m_socket.bind(udp::endpoint(address_v6::any(), m_cfg.endpoint.port()));
    }

    if(args.as_object().count("interface")) {
        auto interface = args.as_object().at("interface");

        if(m_cfg.endpoint.address().is_v4()) {
            m_socket.set_option(multicast::outbound_interface(interface.to<ip::address>().to_v4()));
        } else {
            m_socket.set_option(multicast::outbound_interface(interface.as_uint()));
        }
    }

    m_socket.set_option(multicast::enable_loopback(args.as_object().at("loopback", false).as_bool()));
    m_socket.set_option(multicast::hops(args.as_object().at("hops", 1u).as_uint()));

    COCAINE_LOG_INFO(m_log, "joining multicast group '%s'", m_cfg.endpoint)(
        "uuid", m_locator.uuid()
    );

    m_socket.set_option(multicast::join_group(m_cfg.endpoint.address()));

    const auto announce = std::make_shared<announce_t>();

    m_socket.async_receive_from(buffer(announce->buffer.data(), announce->buffer.size()),
        announce->endpoint,
        std::bind(&multicast_t::on_receive, this, ph::_1, ph::_2, announce)
    );

    m_signals = std::make_shared<dispatch<context_tag>>(name);
    m_signals->on<context::prepared>(std::bind(&multicast_t::on_publish, this, std::error_code()));

    context.listen(m_signals, m_locator.asio());
}
开发者ID:b-xiang,项目名称:cocaine-core,代码行数:49,代码来源:multicast.cpp


示例6: app_dispatch_t

    app_dispatch_t(context_t& context, const std::string& name, std::shared_ptr<overseer_t> overseer_) :
        dispatch<io::app_tag>(name),
        log(context.log(format("%s/dispatch", name))),
        overseer(std::move(overseer_))
    {
        on<io::app::enqueue>(std::make_shared<slot_type>(
            std::bind(&app_dispatch_t::on_enqueue, this, ph::_1, ph::_2, ph::_3)
        ));

        on<io::app::info>(std::bind(&app_dispatch_t::on_info, this));

        // TODO: Temporary here to test graceful app terminating.
        on<io::app::test>([&](const std::string& v) {
            COCAINE_LOG_DEBUG(log, "processing test '%s' event", v);

            if (v == "0") {
                overseer.lock()->terminate();
            } else {
                std::vector<std::string> slaves;
                {
                    auto pool = overseer.lock()->get_pool();
                    for (const auto& p : *pool) {
                        slaves.push_back(p.first);
                    }
                }

                for (auto& s : slaves) {
                    overseer.lock()->despawn(s, overseer_t::despawn_policy_t::graceful);
                }
            }
        });
    }
开发者ID:arssher,项目名称:cocaine-core,代码行数:32,代码来源:app.cpp


示例7:

adhoc_t::adhoc_t(context_t& context, const std::string& _local_uuid, const std::string& name, const dynamic_t& args):
    category_type(context, _local_uuid, name, args),
    m_log(context.log(name))
{
    std::random_device rd;
    m_random_generator.seed(rd());
}
开发者ID:3Hren,项目名称:cocaine-core,代码行数:7,代码来源:adhoc.cpp


示例8:

logging_t::logging_t(context_t& context, io::reactor_t& reactor, const std::string& name, const Json::Value& args):
    category_type(context, reactor, name, args)
{
    auto logger = std::ref(context.logger());

    using cocaine::logging::logger_concept_t;

    on<io::logging::emit>("emit", std::bind(&logger_concept_t::emit, logger, _1, _2, _3));
    on<io::logging::verbosity>("verbosity", std::bind(&logger_concept_t::verbosity, logger));
}
开发者ID:diunko,项目名称:cocaine-core,代码行数:10,代码来源:logging.cpp


示例9:

logging_t::logging_t(context_t& context, io::reactor_t& reactor, const std::string& name, const Json::Value& args):
    api::service_t(context, reactor, name, args),
    implementation<io::logging_tag>(context, name)
{
    auto logger = std::ref(context.logger());

    using cocaine::logging::logger_concept_t;

    on<io::logging::emit>(std::bind(&logger_concept_t::emit, logger, _1, _2, _3));
    on<io::logging::verbosity>(std::bind(&logger_concept_t::verbosity, logger));
}
开发者ID:andrewpsp,项目名称:cocaine-core,代码行数:11,代码来源:logging.cpp


示例10:

agent_t::agent_t(
	context_t ctx )
	:	m_current_state_ptr( &st_default )
	,	m_was_defined( false )
	,	m_state_listener_controller( new impl::state_listener_controller_t )
	,	m_handler_finder{
			// Actual handler finder is dependent on msg_tracing status.
			impl::internal_env_iface_t{ ctx.env() }.is_msg_tracing_enabled() ?
				&agent_t::handler_finder_msg_tracing_enabled :
				&agent_t::handler_finder_msg_tracing_disabled }
	,	m_subscriptions(
			ctx.options().query_subscription_storage_factory()( self_ptr() ) )
	,	m_message_limits(
			message_limit::impl::info_storage_t::create_if_necessary(
				ctx.options().giveout_message_limits() ) )
	,	m_env( ctx.env() )
	,	m_event_queue( nullptr )
	,	m_direct_mbox(
			impl::internal_env_iface_t{ ctx.env() }.create_mpsc_mbox(
				self_ptr(),
				m_message_limits.get() ) )
		// It is necessary to enable agent subscription in the
		// constructor of derived class.
	,	m_working_thread_id( so_5::query_current_thread_id() )
	,	m_agent_coop( 0 )
	,	m_priority( ctx.options().query_priority() )
{
}
开发者ID:crystax,项目名称:android-vendor-sobjectizer,代码行数:28,代码来源:agent.cpp


示例11:

actor_t::actor_t(context_t& context, std::shared_ptr<io::reactor_t> reactor, std::unique_ptr<api::service_t> service):
    m_context(context),
    m_log(context.log(service->prototype().name())),
    m_reactor(reactor)
{
    const io::basic_dispatch_t* prototype = &service->prototype();

    // Aliasing the pointer to the service to point to the dispatch (sub-)object.
    m_prototype = std::shared_ptr<const io::basic_dispatch_t>(
        std::shared_ptr<api::service_t>(std::move(service)),
        prototype
    );
}
开发者ID:bdacode,项目名称:cocaine-core,代码行数:13,代码来源:actor.cpp


示例12: createNodesInCurrentContext

/* create (if necessary) all of the nodes in the current context */
void ContextTree::createNodesInCurrentContext(const context_t &context) {

    CTNode **ctn = &m_root;

    for (size_t i = 0; i < context.size(); i++) {
        ctn = &((*ctn)->m_child[context[i]]);
        if (*ctn == NULL) {
            void *p = m_ctnode_pool.malloc();
            assert(p != NULL);  // TODO: make more robust
            *ctn = new (p) CTNode();
        }
    }
}
开发者ID:floringogianu,项目名称:SkipCTS,代码行数:14,代码来源:ctw.cpp


示例13: identity

auth_t::auth_t(context_t& context):
    m_context(context),
    m_log(context.log("crypto")),
    m_evp_md_context(EVP_MD_CTX_create())
{
    ERR_load_crypto_strings();

    // NOTE: Allowing the exception to propagate here, as this is a fatal error.
    std::vector<std::string> keys(
        context.get<api::storage_t>("storage/core")->list("keys")
    );

    for(std::vector<std::string>::const_iterator it = keys.begin();
        it != keys.end();
        ++it)
    {
        std::string identity(*it);

        std::string object(
            context.get<api::storage_t>("storage/core")->get<std::string>("keys", identity)
        );

        if(object.empty()) {
            COCAINE_LOG_ERROR(m_log, "key for user '%s' is malformed", identity);
            continue;
        }

        // Read the key into the BIO object.
        BIO * bio = BIO_new_mem_buf(const_cast<char*>(object.data()), object.size());
        EVP_PKEY * pkey = NULL;
        
        pkey = PEM_read_bio_PUBKEY(bio, NULL, NULL, NULL);
            
        if(pkey != NULL) {
            m_keys.emplace(identity, pkey);
        } else { 
            COCAINE_LOG_ERROR(
                m_log,
                "key for user '%s' is invalid - %s",
                identity, 
                ERR_reason_error_string(ERR_get_error())
            );
        }

        BIO_free(bio);
    }
    
    COCAINE_LOG_INFO(m_log, "loaded %llu public key(s)", m_keys.size());
}
开发者ID:SSE4,项目名称:cocaine-core,代码行数:49,代码来源:auth.cpp


示例14:

execution_unit_t::execution_unit_t(context_t& context):
    m_asio(new io_service()),
    m_chamber(new io::chamber_t("core:asio", m_asio)),
    m_cron(*m_asio)
{
    m_log = context.log("core:asio", {
        attribute::make("engine", boost::lexical_cast<std::string>(m_chamber->thread_id()))
    });

    m_asio->post(std::bind(&gc_action_t::operator(),
                           std::make_shared<gc_action_t>(this, boost::posix_time::seconds(kCollectionInterval))
                          ));

    COCAINE_LOG_DEBUG(m_log, "engine started");
}
开发者ID:arssher,项目名称:cocaine-core,代码行数:15,代码来源:engine.cpp


示例15: system_error

process_t::process_t(context_t& context, const std::string& name, const dynamic_t& args):
    category_type(context, name, args),
    m_context(context),
    m_log(context.log(name)),
    m_name(name),
    m_working_directory(fs::path(args.as_object().at("spool", "/var/spool/cocaine").as_string()) / name)
{
#ifdef COCAINE_ALLOW_CGROUPS
    int rv = 0;

    if((rv = cgroup_init()) != 0) {
        throw std::system_error(rv, cgroup_category(), "unable to initialize cgroups");
    }

    m_cgroup = cgroup_new_cgroup(m_name.c_str());

    // NOTE: Looks like if this is not done, then libcgroup will chown everything as root.
    cgroup_set_uid_gid(m_cgroup, getuid(), getgid(), getuid(), getgid());

    for(auto type = args.as_object().begin(); type != args.as_object().end(); ++type) {
        if(!type->second.is_object() || type->second.as_object().empty()) {
            continue;
        }

        cgroup_controller* ptr = cgroup_add_controller(m_cgroup, type->first.c_str());

        for(auto it = type->second.as_object().begin(); it != type->second.as_object().end(); ++it) {
            COCAINE_LOG_INFO(m_log, "setting cgroup controller '%s' parameter '%s' to '%s'",
                type->first, it->first, boost::lexical_cast<std::string>(it->second)
            );

            try {
                it->second.apply(cgroup_configurator_t(ptr, it->first.c_str()));
            } catch(const cocaine::error_t& e) {
                COCAINE_LOG_ERROR(m_log, "unable to set cgroup controller '%s' parameter '%s' - %s",
                    type->first, it->first, e.what()
                );
            }
        }
    }

    if((rv = cgroup_create_cgroup(m_cgroup, false)) != 0) {
        cgroup_free(&m_cgroup);

        throw std::system_error(rv, cgroup_category(), "unable to create cgroup");
    }
#endif
}
开发者ID:myutwo,项目名称:cocaine-core,代码行数:48,代码来源:process.cpp


示例16:

node_service_t::node_service_t(context_t& context, io::reactor_t& reactor, const std::string& name):
    api::service_t(context, reactor, name, dynamic_t::empty_object),
    dispatch<io::raft_node_tag<msgpack::object, msgpack::object>>(name),
    m_context(context),
    m_log(context.log(name))
{
    using namespace std::placeholders;

    typedef io::raft_node<msgpack::object, msgpack::object> protocol;

    on<protocol::append>(std::bind(&node_service_t::append, this, _1, _2, _3, _4, _5, _6));
    on<protocol::apply>(std::bind(&node_service_t::apply, this, _1, _2, _3, _4, _5, _6));
    on<protocol::request_vote>(std::bind(&node_service_t::request_vote, this, _1, _2, _3, _4));
    on<protocol::insert>(std::bind(&node_service_t::insert, this, _1, _2));
    on<protocol::erase>(std::bind(&node_service_t::erase, this, _1, _2));
}
开发者ID:andrusha97,项目名称:cocaine-core,代码行数:16,代码来源:raft.cpp


示例17: error_t

darkmetrics_t::darkmetrics_t(context_t& context, peers_t& peers, const dynamic_t& args)
    : unicorn_name_(args.as_object().at("unicorn", dynamic_t::empty_string).as_string())
    , unicorn_prefix_(args.as_object().at("unicorn_prefix", dynamic_t::empty_string).as_string())
    , unicorn_retry_after_(args.as_object().at("unicorn_retry_after_s", 20U).as_uint())
    , enabled_(args.as_object().at("enabled", false).as_bool())
    , ttl_(args.as_object().at("ttl_s", 300U).as_uint())
    , logger_(context.log("vicodyn/darkmetrics"))
    , peers_(peers) {

    if (enabled_) {
        if (unicorn_name_.empty() || unicorn_prefix_.empty()) {
            throw error_t("invalid configuration of darkmetrics: `unicorn` and `unicorn_prefix` are required");
        }
        unicorn_ = api::unicorn(context, unicorn_name_);
    }
    COCAINE_LOG_INFO(logger_, "balancing by system weights is {}", enabled_ ? "on" : "off");
}
开发者ID:shaitan,项目名称:cocaine-plugins,代码行数:17,代码来源:darkmetrics.cpp


示例18: ParseContextMap

bool ParseContextMap(const string &str, context_t &context) {
    istringstream iss(str);
    string element;

    while (getline(iss, element, ',')) {
        istringstream ess(element);

        string tok;
        getline(ess, tok, ':');
        domain_t id = (domain_t) stoi(tok);
        getline(ess, tok, ':');
        float w = stof(tok);

        context.push_back(cscore_t(id, w));
    }

    return true;
}
开发者ID:ModernMT,项目名称:MMT,代码行数:18,代码来源:test_prefixspeed.cpp


示例19: initiate

master_t::master_t(context_t& context, engine_t& engine):
    m_context(context),
    m_log(context.log(
              (boost::format("app/%1%")
               % engine.manifest().name
              ).str()
          )),
    m_engine(engine),
    m_heartbeat_timer(m_engine.loop())
{
    initiate();

    // NOTE: Initialization heartbeat can be different.
    m_heartbeat_timer.set<master_t, &master_t::on_timeout>(this);
    m_heartbeat_timer.start(m_engine.manifest().policy.startup_timeout);

    spawn();
}
开发者ID:griffordson,项目名称:cocaine-core,代码行数:18,代码来源:master.cpp


示例20: error_t

manifest_t::manifest_t(context_t& context, const std::string& name_):
    cached<dynamic_t>(context, "manifests", name_),
    name(name_)
{
    endpoint = cocaine::format("{}/{}.{}", context.config().path().runtime(), name, ::getpid());

    try {
        environment = as_object().at("environment", dynamic_t::empty_object)
            .to<std::map<std::string, std::string>>();
    } catch (const boost::bad_get&) {
        throw cocaine::error_t("environment should be a map of string -> string");
    }

    if(as_object().find("slave") != as_object().end()) {
        executable = as_object().at("slave").as_string();
    } else {
        throw cocaine::error_t("runnable object has not been specified");
    }
}
开发者ID:3Hren,项目名称:cocaine-plugins,代码行数:19,代码来源:manifest.cpp



注:本文中的context_t类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ context_type类代码示例发布时间:2022-05-31
下一篇:
C++ context类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap