Beispiel #1
0
int _QueGet( QUEUE *pQueue, void **ppMsg) {
    QMSG    *pQMsg;

    OsLockMutex( ( void *) pQueue->qMutex, INFINITE);

    pQMsg = RemoveMsgFromQueueHead( pQueue);

    OsUnlockMutex( ( void *) pQueue->qMutex);

    if( pQueue->qMax != QUE_NO_LIMIT) {
#ifdef _WIN32
        ReleaseSemaphore( pQueue->qNotFull, 1, NULL);
#endif
    }
#ifndef _WIN32
    {
        char    b;
        read( pQueue->qNotEmpty[QUEUE_PIPE_IN], &b, 1);
    }
#endif

    *ppMsg = pQMsg->pMsg;

    free( pQMsg);

    return( 0);
}
Beispiel #2
0
int QuePut( QUEUE *pQueue, void *pMsg) {
    if( pQueue->qMax != QUE_NO_LIMIT) { /* bounded queue */
#ifdef _WIN32
        WaitForSingleObject( pQueue->qNotFull, INFINITE);
#elif defined(_arch_dreamcast)
		sem_wait(pQueue->qNotFull);
#endif
    }

    OsLockMutex( ( void *) pQueue->qMutex, INFINITE);

    InsertMsgAtQueueTail( pQueue, pMsg);

    OsUnlockMutex( ( void *) pQueue->qMutex);

#ifdef _WIN32
    ReleaseSemaphore( pQueue->qNotEmpty, 1, NULL);
#elif defined(_arch_dreamcast)
	sem_signal(pQueue->qNotEmpty);
#else
    {
        char    b;
        write( pQueue->qNotEmpty[QUEUE_PIPE_OUT], &b, 1);
    }
#endif

    return( 0);
}