예제 #1
0
파일: mastercmd.c 프로젝트: pi2p/libyasdi
void TMasterCmdFactory_FreeMasterCmd( TMasterCmdReq * mc )
{
   usedcmd--;
   //haeng it to the list of unsed master commands...
   os_thread_MutexLock(&unusedMasterCmdList.Mutex);
   ADDTAIL(&unusedMasterCmdList, &mc->Node);
   os_thread_MutexUnlock(&unusedMasterCmdList.Mutex);   
}
예제 #2
0
SHARED_FUNCTION TNode * TQueue_GetMsg     (TQueue * queue)
{
    TNode * node = NULL;
    //enter critical section: Get first element and remove it from list (not free it)
    os_thread_MutexLock( &queue->messageQueue.Mutex );
    if (!ISLISTEMPTY(&queue->messageQueue))
    {
        node = (TNode*)GETFIRST(&queue->messageQueue);
        REMOVE(node);
    }
    os_thread_MutexUnlock( &queue->messageQueue.Mutex );
    return node;
}
예제 #3
0
SHARED_FUNCTION void TQueue_AddMsg     (TQueue * queue, TNode * node)
{
    /* insert element in list only thread save... */
    os_thread_MutexLock( &queue->messageQueue.Mutex );
    ADDTAIL( &queue->messageQueue, node );
    os_thread_MutexUnlock( &queue->messageQueue.Mutex );
    //if an yasdi task want's to be signaled do it now
    if (queue->waitingTask)
    {
        TTask_Signal( queue->waitingTask );
    }
    if (queue->waitingTimer)
    {
        TTimer_Signal(queue->waitingTimer);
    }

}
예제 #4
0
파일: mastercmd.c 프로젝트: pi2p/libyasdi
TMasterCmdReq * TMasterCmdFactory_GetMasterCmd( TMasterCmdType cmd )
{
   TMasterCmdReq * mc= NULL;
   usedcmd++;
   os_thread_MutexLock(&unusedMasterCmdList.Mutex);
   if (!ISLISTEMPTY( &unusedMasterCmdList ))
   {
      //get it from list...
      mc = (TMasterCmdReq *)GETFIRST(&unusedMasterCmdList);
      REMOVE(&mc->Node);
      
      //reinit the command
      TMasterCmd_Init(mc, cmd);
   }
   os_thread_MutexUnlock(&unusedMasterCmdList.Mutex);
   
   if (mc) return mc;
   
   //nothing free, create an new one...
   return TMasterCmd_Constructor( cmd );
}