本文整理汇总了C++中Slave::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Slave::init方法的具体用法?C++ Slave::init怎么用?C++ Slave::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Slave
的用法示例。
在下文中一共展示了Slave::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv)
{
cout << SectorVersionString << endl;
SlaveConf global_conf;
CmdLineParser clp;
clp.parse(argc, argv);
for (map<string, string>::const_iterator i = clp.m_mDFlags.begin(); i != clp.m_mDFlags.end(); ++ i)
{
if (i->first == "mh")
global_conf.m_strMasterHost = i->second;
else if (i->first == "mp")
global_conf.m_iMasterPort = atoi(i->second.c_str());
else if (i->first == "h")
{
global_conf.m_strHomeDir = i->second;
}
else if (i->first == "ds")
global_conf.m_llMaxDataSize = atoll(i->second.c_str()) * 1024 * 1024;
else if (i->first == "log")
global_conf.m_iLogLevel = atoi(i->second.c_str());
else
{
cout << "warning: unrecognized flag " << i->first << endl;
help();
}
}
string base = "";
if (clp.m_vParams.size() == 1)
base = clp.m_vParams.front();
else if (clp.m_vParams.size() > 1)
cout << "warning: wrong parameters ignored.\n";
Slave s;
if (s.init(&base, &global_conf) < 0)
{
cout << "error: failed to initialize the slave. check slave configurations.\n";
return-1;
}
if (s.connect() < 0)
{
cout << "error: failed to connect to the master, or the connection request is rejected.\n";
return -1;
}
s.run();
s.close();
return 0;
}
示例2: main
int main(int argc, char** argv)
{
Slave s;
int res;
if (argc > 1)
res = s.init(argv[1]);
else
res = s.init();
if (res < 0)
return -1;
if (s.connect() < 0)
return -1;
s.run();
return 1;
}