library/src/events/BP-Events.cc
// This routine is to be used in the main event loop.  When it is called, it examines the events_in
// table and determines whether or not there are events to be processed.
This routine is to be used in the main event loop.  When it is called, it examines the events_in
table and determines whether or not there are events to be processed.
This routine is to be used in the main event loop . When it is called it examines the events_in table and determines whether or not there are events to be processed .
BP_ERROR_T BP_EventLoopPollForEventsAndLockForMainLoop(P_BP_EVENT_MANAGER mgr)
{
	BP_EVENTMGR_VALIDATE_WORKING_ENVIRONMENT(ERR_FAILURE);
	if(!mgr)
		return ERR_FAILURE;
	BP_SemaphorePost(mgr->event_loop_state.lock);
	P_BP_EVENT picked_up_event = NULL;
	size_t event_pickup_count = 0;
	for(;;)
	{
		picked_up_event = BP_EventMgrPickupHighestPriorityEventFromMainLoop
		(
			mgr,
			BP_EVENT_MESSAGES_OUT
		);
		if(!picked_up_event)
			break;
		printf("\n [!!DBG] Got picked up event?: %p - %p", picked_up_event, mgr->events_polled_for_main_loop);
		printf("\n Event Info: %s - %s", picked_up_event->name, picked_up_event->description);
		BP_EventManagerEventsPolledAddEvent(mgr, picked_up_event);
		printf("\n [+] Events Registry Here:");
		BP_HashRegDisplay(mgr->events_polled_for_main_loop, BP_FALSE, BP_TRUE);
		BP_HashRegDisplay(NULL, BP_FALSE, BP_TRUE);
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_EventLoopPollForEventsAndLockForMainLoop ( P_BP_EVENT_MANAGER mgr ) { BP_EVENTMGR_VALIDATE_WORKING_ENVIRONMENT ( ERR_FAILURE ) ; if ( ! mgr ) return ERR_FAILURE ; BP_SemaphorePost ( mgr -> event_loop_state . lock ) ; P_BP_EVENT picked_up_event = NULL ; size_t event_pickup_count = 0 ; for ( ; ; ) { picked_up_event = BP_EventMgrPickupHighestPriorityEventFromMainLoop ( mgr , BP_EVENT_MESSAGES_OUT ) ; if ( ! picked_up_event ) break ; printf ( " \n " , picked_up_event , mgr -> events_polled_for_main_loop ) ; printf ( " \n " , picked_up_event -> name , picked_up_event -> description ) ; BP_EventManagerEventsPolledAddEvent ( mgr , picked_up_event ) ; printf ( " \n " ) ; BP_HashRegDisplay ( mgr -> events_polled_for_main_loop , BP_FALSE , BP_TRUE ) ; BP_HashRegDisplay ( NULL , BP_FALSE , BP_TRUE ) ; } return ERR_SUCCESS ; }
This routine is to be used in the main event loop.
This routine is to be used in the main event loop .
// ensure we have a correct working environment within the event manager // ensure we have a manager // attempt to lock the manager to pickup events // Attempt to pickup event from main loop. // total number of events picked up // loop until we can't pickup any more events // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Pickup Event from events_out %%%%%%%%%%%%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // attempt to pickup highest priority events // ensure we could pickup an event // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // %%% Store Picked Up Events in Poll HashReg %%%%% // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // add event to the event manager /*
	P_BP_EVENT BP_EventMgrPickupEventFromWorker
	(
			P_BP_EVENT_WORKER       worker,
			BP_EVENT_MESSAGE_IN_OUT pickup_from_queue,
			BP_EVENT_PRIORITY       event_priority
	)
	*/ // always return err success unless we simply could not poll (aka missing parameters above)