本文整理汇总了C++中Port::enableBackgroundWrite方法的典型用法代码示例。如果您正苦于以下问题:C++ Port::enableBackgroundWrite方法的具体用法?C++ Port::enableBackgroundWrite怎么用?C++ Port::enableBackgroundWrite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Port
的用法示例。
在下文中一共展示了Port::enableBackgroundWrite方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testCloseOpenRepeats
virtual void testCloseOpenRepeats() {
report(0,"check that opening-closing-opening etc is ok...");
report(0,"non-buffered port:");
Port p;
p.open("/test1");
p.open("/test2");
p.open("/test3");
p.close();
p.open("/test4");
p.close();
report(0,"buffered port:");
BufferedPort<Bottle> p2, p3;
p2.open("/test1");
p2.open("/test2");
p2.open("/in");
p3.open("/out");
Network::connect("/out","/in");
p3.prepare().fromString("10 20 30");
p3.write();
report(0,"wait for input...");
p2.read(true);
report(0,"... got it");
p3.prepare().fromString("10 20 30");
p3.write();
p2.open("/test1");
p3.open("/test2");
Network::connect("/test2","/test1");
p3.prepare().fromString("10 20 30");
p3.write();
report(0,"wait for input...");
p2.read(true);
report(0,"... got it");
report(0,"fast loop on temporary port");
for (int i=0; i<20; i++) {
Port p;
Port p2;
p.open("...");
p2.open("...");
p.close();
}
Port pa;
pa.open("...");
for (int i=0; i<20; i++) {
Port p;
p.enableBackgroundWrite(true);
p.open("...");
NetworkBase::connect(p.getName(),pa.getName());
Bottle b("10 20 30");
p.write(b);
pa.read(b);
p.close();
}
}
示例2: attach
void attach(Port& port) {
stateSema.wait();
this->port = &port;
port.enableBackgroundWrite(true);
stateSema.post();
}
示例3: checkSendReceiveInt
void checkSendReceiveInt()
{
report(0, "check VectorO<int> send receive");
{
Port portIn;
Port portOut;
portOut.open("/harness_sig/vtest/o");
portIn.open("/harness_sig/vtest/i");
Network::connect("/harness_sig/vtest/o", "/harness_sig/vtest/i");
portOut.enableBackgroundWrite(true);
VectorOf<int> vector;
vector.resize(10);
for (unsigned int k = 0; k < vector.size(); k++)
{
vector[k] = k;
}
bool success = true;
portOut.write(vector);
VectorOf<int> tmp;
portIn.read(tmp);
//compare vector and tmp
if (tmp.size() != vector.size())
{
success = false;
}
else
{
for (unsigned int k = 0; k < vector.size(); k++)
{
if (tmp[k] != vector[k])
success = false;
}
}
checkTrue(success, "VectorOf<int> was sent and received correctly");
portOut.interrupt();
portOut.close();
portIn.interrupt();
portIn.close();
}
report(0, "check VectorOf<int> bottle compatibility");
{
//write the same vector again and receive it as a bottle
Port portIn;
Port portOut;
bool success = true;
portOut.open("/harness_sig/vtest/o");
portIn.open("/harness_sig/vtest/i");
Network::connect("/harness_sig/vtest/o", "/harness_sig/vtest/i");
portOut.enableBackgroundWrite(true);
VectorOf<int> vector;
vector.resize(10);
for (unsigned int k = 0; k < vector.size(); k++)
{
vector[k] = k;
}
portOut.write(vector);
Bottle tmp2;
success = portIn.read(tmp2);
checkTrue(success,"correctly read from the port");
//compare vector and tmp
success = true;
if (tmp2.size() != vector.size())
{
success = false;
}
else
{
for (unsigned int k = 0; k < vector.size(); k++)
{
if (tmp2.get(k).asInt32() != vector[k])
success = false;
}
}
checkTrue(success, "VectorOf<int> was received correctly in a Bottle");
portOut.interrupt();
portOut.close();
portIn.interrupt();
portIn.close();
}
}