Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

PhEventNext()

Provide synchronous event notification

Synopsis:

int PhEventNext( void *buffer,
                 unsigned size );

Library:

ph

Description:

This function provides a completely synchronous event-notification mechanism. It causes the application to become REPLY-blocked on the currently attached Photon channel until an event occurs.

For asynchronous event notification, see PhEventRead() and PhEventArm().

If the application's event queue contains an event when this call is made, Photon replies immediately with that event.


Note: If your application uses widgets, don't try to write your own event-handling loop; use PtMainLoop() or PtProcessEvent() instead.

Returns:

Ph_EVENT_MSG
Successful completion.
Ph_RESIZE_MSG
The Ph_DYNAMIC_BUFFER flag was set in PhAttach(), and there's a pending Photon event that's larger than the client's event buffer. This event that indicates how large the client's buffer needs to be to receive the entire event message.
-1
An error occurred.

Examples:

#define EVENT_SIZE    sizeof( PhEvent_t ) + 1000

main( int argc, char *argv[] )
{
     PhEvent_t *event;
     
     if( initialize() == -1 )
          exit( EXIT_FAILURE );
     
     if( NULL == ( event = malloc( EVENT_SIZE ) ) )
          exit( EXIT_FAILURE );
     
     while( 1 ) {
          switch( PhEventNext( event, EVENT_SIZE ) ) {
              case Ph_EVENT_MSG:
                 PtEventHandler( event );
                 break;
              case -1:
                 perror( "PhEventNext failed" );
                 break;
     }
   }
}

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PhAttach(), PhEvent_t, PhEventPeek(), PhEventRead(), PhGetMsgSize(), PtEventHandler()

"Collecting events" in the Events chapter of the Photon Programmer's Guide