本文整理汇总了C++中YARPSemaphore::Post方法的典型用法代码示例。如果您正苦于以下问题:C++ YARPSemaphore::Post方法的具体用法?C++ YARPSemaphore::Post怎么用?C++ YARPSemaphore::Post使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YARPSemaphore
的用法示例。
在下文中一共展示了YARPSemaphore::Post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Body
virtual void Body()
{
int ct = 0;
char txt[128] = "Hello there";
char reply[128] = "Not set";
YARPUniqueNameID* id = NULL;
do
{
out.Wait();
cout << "Looking up name" << endl;
cout.flush();
out.Post();
id = YARPNameService::LocateName(REG_LOCATE_NAME, NET_NAME);
if (id->getServiceType () == YARP_NO_SERVICE_AVAILABLE)
{
ACE_DEBUG ((LM_DEBUG, "can't locate name, bailing out\n"));
return;
}
id->setServiceType(YARP_TCP);
YARPEndpointManager::CreateOutputEndpoint (*id);
YARPEndpointManager::ConnectEndpoints (*id, SRC_NAME);
YARPTime::DelayInSeconds(0.2);
}
while (!id->isValid());
int x = 42;
while (!IsTerminated())
{
out.Wait();
cout << "Preparing to send: " << txt << endl;
cout.flush();
out.Post();
YARPMultipartMessage smsg(2);
smsg.Set(0,txt,sizeof(txt));
smsg.Set(1,(char*)(&x),sizeof(x));
YARPMultipartMessage rmsg(2);
double y = 999;
rmsg.Set(0,reply,sizeof(reply));
rmsg.Set(1,(char*)(&y),sizeof(y));
cout << "***sending: " << txt << endl;
cout.flush();
YARPSocketSyncComm::Send(*id,smsg,rmsg);
x++;
out.Wait();
cout << "Got reply : " << reply << " and number " << y << endl;
cout.flush();
out.Post();
YARPTime::DelayInSeconds(2.0);
ct++;
sprintf(txt, "And a-%d", ct);
}
}
示例2: Body
virtual void Body()
{
int ct = 0;
char txt[128] = "Hello there";
char reply[128] = "Not set";
YARPUniqueNameID* id = NULL;
cout << "Here" << endl;
cout.flush();
do
{
out.Wait();
cout << "Looking up name" << endl;
cout.flush();
out.Post();
id = YARPNameService::LocateName(REG_LOCATE_NAME, NET_NAME);
if (id->getServiceType () == YARP_NO_SERVICE_AVAILABLE)
{
ACE_DEBUG ((LM_DEBUG, "can't locate name, bailing out\n"));
return;
}
YARPEndpointManager::CreateOutputEndpoint (*id);
YARPEndpointManager::ConnectEndpoints (*id, SRC_NAME);
if (!id->isValid())
{
YARPTime::DelayInSeconds(0.2);
}
}
while (!id->isValid());
while (!IsTerminated())
{
out.Wait();
cout << "Preparing to send: " << txt << endl;
cout.flush();
out.Post();
YARPSyncComm::Send(id->getNameID(),txt,sizeof(txt),reply,sizeof(reply));
out.Wait();
cout << "Got reply : " << reply << endl;
cout.flush();
out.Post();
YARPTime::DelayInSeconds(2.0);
ct++;
sprintf(txt, "And a-%d", ct);
}
}
示例3: SetGyro
void SetGyro(double n_yaw, double n_pitch, double n_roll)
{
mutex.Wait();
state.yaw = n_yaw; state.pitch = n_pitch; state.roll = n_roll;
last_gyro_time = YARPTime::GetTimeAsSeconds();
mutex.Post();
}
示例4: OnRead
virtual void OnRead()
{
assert(Read(0));
state_mutex.Wait();
state_joint = Content();
state_mutex.Post();
}
示例5: MarkTarget
void MarkTarget(int id)
{
printf("Marking current region as target %d\n", id);
state_mutex.Wait();
target_manager.Set(id,global_theta,global_phi);
state_mutex.Post();
}
示例6: SetJoints
void SetJoints(JointPos& j)
{
mutex.Wait();
state.joints = j;
last_neck_time = YARPTime::GetTimeAsSeconds();
mutex.Post();
}
示例7: RegisterName
int YARPSocketNameService::RegisterName(const char *name)
{
int name_status = -1;
int result = -1;
//static YARPInputSocket sock;
//sock.Register(name);
//test_global = &sock;
DBG(5) printf("^^^^^^^^ checking for previous definitions\n");
if (GetThreadSocket()==NULL)
{
DBG(5) printf("^^^^^^^^ checks out okay\n");
int pid = my_getpid();
mutex.Wait();
DBG(5) printf("^^^^^^^^ creating\n");
YARPInputSocket *is = new YARPInputSocket;
is_map[pid] = is;
DBG(5) printf("^^^^^^^^ preparing to register\n");
is->Register(name);
result = is->GetAssignedPort();
mutex.Post();
DBG(5) printf("^^^^^^^^ Made an input socket handler\n");
fflush(stdout);
}
return result;
}
示例8: Get
int Get(HeadState& dest)
{
int result = IsValid();
mutex.Wait();
dest = state;
mutex.Post();
return result;
}
示例9: SetEyes
void SetEyes(double n_tilt, double n_left_pan, double n_right_pan)
{
mutex.Wait();
state.tilt = n_tilt; state.left_pan = n_left_pan;
state.right_pan = n_right_pan;
last_eyes_time = YARPTime::GetTimeAsSeconds();
mutex.Post();
}
示例10: ResetControl
void ResetControl()
{
mutex.Wait();
HeadMessage& msg = out_cmd.Content();
msg.type = HeadMsgNonValid;
out_cmd.Write();
mutex.Post();
}
示例11: IsValid
int IsValid()
{
double now = YARPTime::GetTimeAsSeconds();
mutex.Wait();
int result = /*(now-last_gyro_time<1)&&*/(now-last_eyes_time<1)&&
(now-last_neck_time<1);
mutex.Post();
return result;
}
示例12: OnRead
virtual void OnRead()
{
assert(Read(0));
JointPos& datum = Content();
// printf("eye %g %g %g\n", datum(1), datum(2), datum(3));
head_state_manager.SetEyes(datum(1), datum(2), datum(3));
// head_state_manager.SetNeck(datum(6), datum(7), datum(4), datum(5));
head_state_manager.SetNeck(datum(4), datum(5), datum(7), datum(6));
head_state_manager.SetJoints(datum);
wake_up_call.Post();
}
示例13: RemovePort
// LATER: find out why this is commented out.
static void RemovePort(YARPPort *port)
{
ACE_UNUSED_ARG(port);
port_list_mutex.Wait();
//#ifndef __QNX__
// port_list.erase(port);
//#endif
port_list_mutex.Post();
}
示例14: SetNeck
void SetNeck(double n_tilt, double n_roll,
double n_lean, double n_pan)
{
mutex.Wait();
state.neck_tilt = n_tilt;
state.neck_roll = n_roll;
state.neck_lean = n_lean;
state.neck_pan = n_pan;
//last_neck_time = YARPTime::GetTimeAsSeconds();
mutex.Post();
}
示例15:
YARPInputSocket *GetThreadSocket()
{
int pid = my_getpid();
YARPInputSocket *result = NULL;
mutex.Wait();
if (is_map.find(pid)!=is_map.end())
{
result = is_map[pid];
}
mutex.Post();
return result;
}