Ejemplo n.º 1
0
void main(void){
  ES_Event MyEvent;
  bool bReturn;
  
  ES_InitQueue( TestQueue, ARRAY_SIZE(TestQueue) );
  MyEvent.EventType = 0;
  MyEvent.EventParam = 1;
  bReturn = ES_EnQueueFIFO( TestQueue, MyEvent );
  bReturn +=1; // keep that sily optimizer away
  
    // Try stuffing one on using the LIFO rule
  MyEvent.EventType = 10;
  MyEvent.EventParam = 11;
  bReturn = ES_EnQueueLIFO( TestQueue, MyEvent );
  bReturn +=1; // keep that sily optimizer away
  
  // at this point, the events in the queue should be 11,0
  // so pull off the 11, leaving 1 entry
  NumLeft = ES_DeQueue( TestQueue, &MyEvent);
  if ( NumLeft != 1)
    bReturn = 0;  

  MyEvent.EventType = 2;
  MyEvent.EventParam = 3;
  bReturn = ES_EnQueueFIFO( TestQueue, MyEvent );
  bReturn +=1; // keep that sily optimizer away
  
  MyEvent.EventType = 4;
  MyEvent.EventParam = 5;
  bReturn = ES_EnQueueFIFO( TestQueue, MyEvent );
  bReturn +=1; // keep that sily optimizer away
  
  // queue is now full so this one should fail
  MyEvent.EventType = 6;
  MyEvent.EventParam = 7;
  bReturn = ES_EnQueueFIFO( TestQueue, MyEvent );
  bReturn +=1; // keep that sily optimizer away
  
  // at this point, the events in the queue should be 0,2,4
  // so pull off the 0, leaving 2 entries
  NumLeft = ES_DeQueue( TestQueue, &MyEvent);
  if ( NumLeft != 2)
    bReturn = 0;  
  // Try stuffing one on using the LIFO rule
  MyEvent.EventType = 8;
  MyEvent.EventParam = 9;
  bReturn = ES_EnQueueLIFO( TestQueue, MyEvent );
  bReturn +=1; // keep that sily optimizer away
  
  // at this point, the events in the queue should be 8,2,4
  // so pull off the 8, leaving 2 entries
  NumLeft = ES_DeQueue( TestQueue, &MyEvent);
  NumLeft += 3; //to keep the compiler from optimizing away the last save
  
  while(1)
    ;
}
Ejemplo n.º 2
0
/****************************************************************************
 Function
   ES_PostToServiceLIFO
 Parameters
   uint8_t : Which service to post to (index into ServDescList)
   ES_Event : The Event to be posted
 Returns
   boolean : False if the post function failed during execution
 Description
   Posts, using LIFO strategy, to one of the services' queues
 Notes
   used by the Defer/Recall event capability
 Author
   J. Edward Carryer, 11/02/13
****************************************************************************/
bool ES_PostToServiceLIFO( uint8_t WhichService, ES_Event TheEvent){
  if ((WhichService < ARRAY_SIZE(EventQueues)) &&
      (ES_EnQueueLIFO( EventQueues[WhichService].pMem, TheEvent) == 
                                                                true )){
    Ready |= BitNum2SetMask[WhichService]; // show queue as non-empty
    return true;
  } else
    return false;
}