本文整理汇总了C++中EventLoopImpl类的典型用法代码示例。如果您正苦于以下问题:C++ EventLoopImpl类的具体用法?C++ EventLoopImpl怎么用?C++ EventLoopImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventLoopImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
if (argc < 4) {
std::cout << "Usage: " << argv[0] << "<host> <port> <local/remote>" << std::endl;
exit(1);
}
NetworkOptions options;
options.set_host(argv[1]);
options.set_port(atoi(argv[2]));
options.set_max_packet_size(1024);
if (strcmp(argv[3], "local") == 0) {
options.set_socket_family(PF_UNIX);
options.set_sin_path("/tmp/__echoserver__");
} else {
options.set_socket_family(PF_INET);
}
bool perf = false;
if (argc > 4 && strcmp(argv[4], "perf") == 0)
perf = true;
EventLoopImpl ss;
EchoClient echo_client(&ss, options, perf);
echo_client.Start();
ss.loop();
return 0;
}
示例2: EventLoop_dtor
static void FOG_CDECL EventLoop_dtor(EventLoop* self)
{
EventLoopImpl* d = self->_d;
if (d)
d->release();
}
示例3: main
int main(int argc, char* argv[]) {
if (argc != 4) {
usage();
exit(1);
}
clustername = argv[1];
sp_string zkhostport = argv[2];
zkroot = argv[3];
// Make sure that zkroot starts with '/'
if (zkroot.substr(0, 1) != "/") {
LOG(ERROR) << "zkroot should start with /" << std::endl;
::exit(1);
}
// remove trailing '/'
if (zkroot[zkroot.size() - 1] == '/') {
zkroot = std::string(zkroot, 0, zkroot.size() - 1);
}
EventLoopImpl ss;
zkclient = new ZKClient(zkhostport, &ss);
zkclient->CreateNode(zkroot, "Heron Cluster " + clustername, false,
[](sp_int32 status) { ZkRootDone(status); });
ss.loop();
}
示例4: TEST
TEST(PiperTest, test_piper) {
EventLoopImpl* eventLoop = new EventLoopImpl();
std::thread* thread = new std::thread(RunningEventLoop, eventLoop);
Piper* piper = new Piper(eventLoop);
Resource* resource = new Resource();
resource->count = 0;
auto cb = [resource](){ resource->count++; };
piper->ExecuteInEventLoop(cb);
sleep(1);
EXPECT_EQ(resource->count, 1);
piper->ExecuteInEventLoop(cb);
sleep(1);
EXPECT_EQ(resource->count, 2);
eventLoop->loopExit();
// Wait for the thread to terminate
thread->join();
delete piper;
delete resource;
delete eventLoop;
delete thread;
}
示例5: main
int main(int argc, char* argv[])
{
if (argc < 4) {
std::cout << "Usage: " << argv[0] << " <host> <port> <local/remote>" << std::endl;
exit(1);
}
NetworkOptions options;
options.set_host(argv[1]);
options.set_port(atoi(argv[2]));
options.set_max_packet_size(1024);
if (strcmp(argv[3], "local") == 0) {
options.set_socket_family(PF_UNIX);
options.set_sin_path("/tmp/__echoserver__");
} else {
options.set_socket_family(PF_INET);
}
EventLoopImpl ss;
EchoServer echo_server(&ss, options);
if (echo_server.Start() != 0) {
// What the hell happened
std::cout << "Server failed to start\n";
return 1;
}
ss.loop();
return 0;
}
示例6: TEST
// Test simple data tuples drain
TEST(TupleCache, test_simple_data_drain) {
sp_int32 data_tuples_count = 23354;
EventLoopImpl ss;
sp_uint32 drain_threshold = 1024 * 1024;
heron::stmgr::TupleCache* g = new heron::stmgr::TupleCache(&ss, drain_threshold);
std::map<sp_int32, sp_int32> data_tuples;
data_tuples[1] = data_tuples_count;
std::map<sp_int32, sp_int32> ack_tuples;
std::map<sp_int32, sp_int32> fail_tuples;
Drainer* drainer = new Drainer(data_tuples, ack_tuples, fail_tuples);
g->RegisterDrainer(&Drainer::Drain, drainer);
heron::proto::api::StreamId dummy;
dummy.set_id("stream");
dummy.set_component_name("comp");
for (sp_int32 i = 0; i < data_tuples_count; ++i) {
heron::proto::system::HeronDataTuple tuple;
tuple.set_key(RandUtils::lrand());
g->add_data_tuple(1, dummy, tuple);
}
// 300 milliseconds second
auto cb = [&ss](EventLoopImpl::Status status) { DoneHandler(&ss, status); };
ss.registerTimer(std::move(cb), false, 300000);
ss.loop();
EXPECT_EQ(drainer->Verify(), true);
delete drainer;
delete g;
}
示例7: main
int main(int argc, char* argv[]) {
if (argc != 7) {
std::cout
<< "Usage: " << argv[0]
<< " <host> <master-port> <topology-name> <zk_hostport> <zkroot> <sgmrid:host:port,...>"
<< std::endl;
std::cout << "If zk_hostportlist is empty please say LOCALMODE\n";
::exit(1);
}
std::string myhost = argv[1];
sp_int32 master_port = atoi(argv[2]);
std::string topology_name = argv[3];
std::string zkhostportlist = argv[4];
if (zkhostportlist == "LOCALMODE") {
zkhostportlist = "";
}
std::string topdir = argv[5];
std::vector<std::string> stmgrs = StrUtils::split(argv[6], ",");
EventLoopImpl ss;
NetworkOptions options;
options.set_host(myhost);
options.set_port(master_port);
options.set_max_packet_size(1_MB);
options.set_socket_family(PF_INET);
heron::tmaster::TMasterServer tmaster(&ss, options, topology_name, zkhostportlist, topdir,
stmgrs);
ss.loop();
return 0;
}
示例8: EventLoop_quit
static err_t FOG_CDECL EventLoop_quit(EventLoop* self)
{
EventLoopImpl* d = self->_d;
if (d == NULL)
return ERR_RT_INVALID_STATE;
return d->quit();
}
示例9: EventLoop_runAllPending
static err_t FOG_CDECL EventLoop_runAllPending(EventLoop* self)
{
EventLoopImpl* d = self->_d;
if (d == NULL)
return ERR_RT_INVALID_STATE;
return d->runAllPending();
}
示例10: EventLoop_postTask
static err_t FOG_CDECL EventLoop_postTask(EventLoop* self, Task* task, bool nestable, uint32_t delay)
{
EventLoopImpl* d = self->_d;
if (d == NULL)
return ERR_RT_INVALID_STATE;
return d->postTask(task, nestable, delay);
}
示例11: EventLoop_removeObserver
static err_t FOG_CDECL EventLoop_removeObserver(EventLoop* self, EventLoopObserver* obj)
{
EventLoopImpl* d = self->_d;
if (d == NULL)
return ERR_RT_INVALID_STATE;
return d->removeObserver(obj);
}
示例12: EventLoop_ctorCopy
static void FOG_CDECL EventLoop_ctorCopy(EventLoop* self, const EventLoop* other)
{
EventLoopImpl* d = other->_d;
if (d != NULL)
d = d->addRef();
self->_d = d;
}
示例13: start_http_client
void start_http_client(sp_uint32 _port, sp_uint64 _requests, sp_uint32 _nkeys) {
port = _port;
ntotal = _requests;
nkeys = _nkeys;
EventLoopImpl ss;
AsyncDNS dns(&ss);
HTTPClient client(&ss, &dns);
SendRequest(&client);
ss.loop();
}
示例14: terminate_server
void terminate_server(sp_uint32 port) {
NetworkOptions options;
options.set_host(LOCALHOST);
options.set_port(port);
options.set_max_packet_size(1024 * 1024);
options.set_socket_family(PF_INET);
EventLoopImpl ss;
Terminate ts(&ss, options);
ts.Start();
ss.loop();
}
示例15: start_client
void start_client(sp_uint32 port, sp_uint64 requests) {
NetworkOptions options;
options.set_host(LOCALHOST);
options.set_port(port);
options.set_max_packet_size(1024 * 1024);
options.set_socket_family(PF_INET);
EventLoopImpl ss;
OrderClient client(&ss, options, requests);
client.Start();
ss.loop();
}