Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/ph/pheventpeek.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/ph/pheventpeek.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/ph/pheventpeek.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/ph/pheventpeek.html on line 8

PhEventPeek()

Check to see if an event is pending

Synopsis:

int PhEventPeek( void *buffer,
                 unsigned size );

Library:

ph

Description:

This function lets you check if an event is pending on the current Photon channel:

Since this function is nonblocking, you should find it useful for applications that need to run continuously and still interact with Photon.

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


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.
0
No message was available.
-1
An error occurred.

Examples:

#define EVENT_SIZE    sizeof( PhEvent_t ) + 1000

main( int argc, char *argv[] )
{
     int go = 1, count = 0;
     PhEvent_t *event;

     if( initialize() == -1 )
          exit( EXIT_FAILURE );
     
     if( NULL == ( event = malloc( EVENT_SIZE ) ) )
          exit( EXIT_FAILURE );
     
     while( go ) {
          if(( ++count & 15) == 0) {
               PgFlush();
               switch( PhEventPeek( event, EVENT_SIZE ) {
                    case Ph_EVENT_MSG:
                       PtEventHandler( event );
                       break;
                    case -1:
                       perror( "PhEventPeek failed" );
                       break;
               }
          }
          iterate_graphics_process();
     }
     exit( 0 );
}

Classification:

Photon

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

PhAttach(), PhEvent_t, PhEventNext(), PhEventRead(), PtEventHandler()

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


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/photon/lib_ref/ph/pheventpeek.html on line 196

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/photon/lib_ref/ph/pheventpeek.html on line 196