src/libYARP_OS/src/Port.cpp
Sendable *Port::Acquire(int wait)
{
	int go = 0;
	Sendable *result = NULL;
	if (wait)
	{
		out_mutex.Wait();
		while (!has_input)
		{
			out_mutex.Post();
			something_to_read.Wait();
			out_mutex.Wait();
		}
		out_mutex.Post();
		go = 1;
	}
	else
	{
		// HIT unfinished
		go = something_to_read.PollingWait();
	}

	if (go && !IsTerminated())
	{
		out_mutex.Wait();
		ACE_ASSERT (!accessing);
		if (p_receiver_latest.Ptr()!=NULL)
		{
			YARP_DBG(THIS_DBG) ((LM_DEBUG, "&&& READ from latest space\n"));
			p_receiver_latest.Switch(p_receiver_access);
			has_input = 0;
		}
		result = p_receiver_access.Ptr();

		if (asleep)
		{
			wakeup.Post();
		}
		accessing = 1;
		out_mutex.Post();
	}

	return result;
}
///
/// this together with Relinquish is part of the Read process.
///
///
///
this together with Relinquish is part of the Read process.
this together with Relinquish is part of the Read process .
Sendable *Port::Acquire(int wait)
{
	int go = 0;
	Sendable *result = NULL;
	if (wait)
	{
		out_mutex.Wait();
		while (!has_input)
		{
			out_mutex.Post();
			something_to_read.Wait();
			out_mutex.Wait();
		}
		out_mutex.Post();
		go = 1;
	}
	else
	{
		go = something_to_read.PollingWait();
	}
	if (go && !IsTerminated())
	{
		out_mutex.Wait();
		ACE_ASSERT (!accessing);
		if (p_receiver_latest.Ptr()!=NULL)
		{
			YARP_DBG(THIS_DBG) ((LM_DEBUG, "&&& READ from latest space\n"));
			p_receiver_latest.Switch(p_receiver_access);
			has_input = 0;
		}
		result = p_receiver_access.Ptr();
		if (asleep)
		{
			wakeup.Post();
		}
		accessing = 1;
		out_mutex.Post();
	}
	return result;
}
Sendable * Port :: Acquire ( int wait ) { int go = 0 ; Sendable * result = NULL ; if ( wait ) { out_mutex . Wait ( ) ; while ( ! has_input ) { out_mutex . Post ( ) ; something_to_read . Wait ( ) ; out_mutex . Wait ( ) ; } out_mutex . Post ( ) ; go = 1 ; } else { go = something_to_read . PollingWait ( ) ; } if ( go && ! IsTerminated ( ) ) { out_mutex . Wait ( ) ; ACE_ASSERT ( ! accessing ) ; if ( p_receiver_latest . Ptr ( ) != NULL ) { YARP_DBG ( THIS_DBG ) ( ( LM_DEBUG , " \n " ) ) ; p_receiver_latest . Switch ( p_receiver_access ) ; has_input = 0 ; } result = p_receiver_access . Ptr ( ) ; if ( asleep ) { wakeup . Post ( ) ; } accessing = 1 ; out_mutex . Post ( ) ; } return result ; }
this together with Relinquish is part of the Read process.
this together with Relinquish is part of the Read process .
// HIT unfinished