ClRcT clJobQueueInit(ClJobQueueT* hdl, ClUint32T maxJobs, ClUint32T maxTasks)
{
    ClRcT rc;
    hdl->flags = 0;
    hdl->queue = 0;
    hdl->pool  = 0;

    rc = clOsalMutexInit(&hdl->mutex);
    if (rc != CL_OK) goto error;

    rc = clQueueCreate(maxJobs, deleteCallback, deleteCallback, &hdl->queue);
    if (rc != CL_OK) goto error;

    rc = clTaskPoolCreate(&hdl->pool, maxTasks, clJobQueuePreIdle, hdl);
    if (rc != CL_OK) goto error;

    hdl->flags |= CreatedQueue | CreatedPool | Running;
    return CL_OK;  

    error:
    clOsalMutexDestroy(&hdl->mutex);
    if (hdl->pool) clTaskPoolDelete(hdl->pool);
    if (hdl->queue) clQueueDelete(&hdl->queue);

    hdl->queue = 0;
    hdl->pool  = 0;
    return rc;
}
ClRcT clMsgQueueFinalize(void)
{
    ClRcT rc;
    
    rc = clOsalMutexDestroy(&gClQueueDbLock);
    if(rc != CL_OK)
        clLogError("QUE", "FIN", "Failed to destroy queue db mutex. error code [0x%x].", rc);
    
    rc = clOsalMutexDestroy(&gClLocalQsLock);
    if(rc != CL_OK)
        clLogError("QUE", "FIN", "Failed to destroy the local queues' mutex. error code [0x%x].", rc);

    rc = clHandleDatabaseDestroy(gClMsgQDatabase);
    if(rc != CL_OK)
        clLogError("QUE", "FIN", "Failed to delete the Queue Handle database. error code [0x%x].", rc);
    
    return rc;
}
ClRcT 
clLogUtilLibInitialize(void)
{
    ClRcT  rc = CL_OK;
    ClCharT *pEOName = NULL;
    if( gUtilLibInitialized == CL_TRUE )
    {
        return CL_OK;
    }
    rc = clOsalMutexErrorCheckInit(&gLogMutex);
    if( CL_OK != rc )
    {
        fprintf(stderr, "Mutex init failed rc[0x %x]\n", rc);
        return rc;
    }
    rc = clOsalCondInit(&gLogCond);
    if( CL_OK != rc )
    {
        fprintf(stderr, "Cond init failed rc[0x %x]\n", rc);
        clOsalMutexDestroy(&gLogMutex);
        return rc;
    }
    pEOName = CL_EO_NAME;
    if(pEOName && !strncasecmp(pEOName, "LOG", 3))
    {
        gClLogServer = CL_TRUE;
    }

    clLogDebugFilterInitialize();

    gUtilLibInitialized = CL_TRUE;
    rc = clOsalTaskCreateAttached((ClCharT *)CL_LOG_UTIL_TASK_NAME, CL_OSAL_SCHED_OTHER,
            CL_OSAL_THREAD_PRI_NOT_APPLICABLE, CL_OSAL_MIN_STACK_SIZE,
            clLogDeferredHandler, NULL, &taskId);
    if( CL_OK != rc )
    {
        fprintf(stderr, "Thread creation failed rc[0x %x]", rc);
        clOsalCondDestroy(&gLogCond);
        clOsalMutexDestroy(&gLogMutex);
        return rc;
    }
    
    return CL_OK;
}
void clMsgQueueFree(ClMsgQueueInfoT *pQInfo)
{
    ClRcT rc = CL_OK;
    SaNameT qName = {strlen("--Unknow--"), "--Unknow--"};
    ClUint32T i;

    CL_OSAL_MUTEX_LOCK(&pQInfo->qLock);

    (void)clMsgUnblockThreadsOfQueue(pQInfo);

    if(pQInfo->unlinkFlag == CL_FALSE && pQInfo->pQueueEntry != NULL)
    {
        saNameCopy(&qName, &pQInfo->pQueueEntry->qName);
    }
    
    if(pQInfo->timerHandle != 0)
    {
        rc = clTimerDelete(&pQInfo->timerHandle);
        if(rc != CL_OK)
            clLogError("QUE", "FREE", "Failed to delete [%.*s]'s timer handle. error code [0x%x].", 
                       qName.length, qName.value, rc);
    }
    
    clMsgQueueEmpty(pQInfo);

    for(i = 0; i < CL_MSG_QUEUE_PRIORITIES ; i++)
    {
        rc = clCntDelete(pQInfo->pPriorityContainer[i]);
        if(rc != CL_OK)
            clLogError("QUE", "FREE", "Failed to delete the [%.*s]'s [%d] priority container. error code [0x%x].", 
                       qName.length, qName.value, i, rc);
        else
            pQInfo->pPriorityContainer[i] = 0;
    }

    rc = clOsalCondDelete(pQInfo->qCondVar);
    if(rc != CL_OK)
        clLogError("QUE",  "FREE", "Failed to delete the [%.*s]'s condtional variable. error code [0x%x].",
                   qName.length, qName.value, rc);

    pQInfo->qCondVar = 0;

    CL_OSAL_MUTEX_UNLOCK(&pQInfo->qLock);

    rc = clOsalMutexDestroy(&pQInfo->qLock);
    if(rc != CL_OK)
        clLogError("QUE",  "FREE", "Failed to delete the [%.*s]'s lock. error code [0x%x].",
                   qName.length, qName.value, rc);

    clLogDebug("QUE", "FREE", "Freed the queue [%.*s].", qName.length, qName.value);

    return;
}
static ClRcT clAmsListHeadInit(ClAmsListHeadT *pList)
{
    ClRcT rc;

    clOsalMutexInit(&pList->mutex);
    rc = clOsalCondInit(&pList->cond);
    if(rc != CL_OK)
    {
        clLogError("AMS", "INIT", "Failed to create a condtional variable. error code [0x%x].", rc);
        clOsalMutexDestroy(&pList->mutex);
        return rc;
    }
    pList->numElements = 0;
    CL_LIST_HEAD_INIT(&pList->list);
    return CL_OK;
}
ClRcT clJobQueueDelete(ClJobQueueT* hdl)
{
    if(hdl->flags & CreatedQueue) 
    {
        /*
         * Prevent parallel job queue pushes during a queue delete.
         */
        JQ_PFX(hdl);
        hdl->flags &= ~Running;
        JQ_SFX(hdl);
        clJobQueueStop(hdl);
        if (hdl->flags & CreatedPool) clTaskPoolDelete(hdl->pool);
        clQueueDelete(&hdl->queue);
        clOsalMutexDestroy(&hdl->mutex);
    }
    if (hdl->flags & CreatedJobQueue) clHeapFree(hdl);
    return CL_OK;
}
ClRcT clMsgFinalizeBlockFin(void)
{
    ClRcT rc;
    
    rc = clMsgEventFinalize();
    if(rc != CL_OK)
        clLogError("MSG", "BLOCK", "Failed to finalize event library. error code [0x%x].", rc);

    rc = clOsalMutexDestroy(&gFinBlockMutex);
    if(rc != CL_OK)
        clLogError("MSG", "BLOCK", "Failed to delete a mutex. error code [0x%x].", rc);

    rc = clOsalCondDelete(gFinBlockCond);
    if(rc != CL_OK)
        clLogError("MSG", "BLOCK", "Failed to delete a conditional variable. error code [0x%x].", rc);

    return rc;
}
ClRcT clEoQueueDeleteSync(ClIocPriorityT priority, ClBoolT force)
{
    ClEoQueueT *pQueue = NULL;
    ClRcT rc = CL_EO_RC(CL_ERR_INVALID_PARAMETER);

    if(priority >= CL_IOC_MAX_PRIORITIES)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Invalid parameter\n"));
        goto out;
    }

    rc = CL_EO_RC(CL_ERR_NOT_EXIST);

    CL_EO_QUEUE_LOCK(&gClEoQueueMutex);
    if(!(pQueue = gpClEoQueues[priority]))
    {
        CL_EO_QUEUE_UNLOCK(&gClEoQueueMutex);
        CL_DEBUG_PRINT(CL_DEBUG_WARN, ("Queue priority:%d doesnt exist\n",priority));
        goto out;
    }
    gpClEoQueues[priority] = NULL;
    CL_EO_QUEUE_UNLOCK(&gClEoQueueMutex);

    /*Quiesce the queue*/
    pQueue->state = CL_EO_QUEUE_STATE_QUIESCED;

    /*Delete the thread pool associated with the queue*/
    rc = CL_OK;
    if(pQueue->pThreadPool)
    {
        rc = clThreadPoolDeleteSync((ClThreadPoolHandleT)pQueue->pThreadPool, 
                                    force);
        if(rc != CL_OK)
        {
            CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Error deleting thread pool.rc=0x%x\n",rc));
        }
    }
    clOsalMutexDestroy(&pQueue->mutex);
    clOsalCondDestroy(&pQueue->cond);
    clHeapFree(pQueue);
    out:
    return rc;
} 
ClRcT clMemPartFinalize(ClMemPartHandleT *pHandle)
{
    STATUS rc = 0;
    ClMemPartT *pMemPart = NULL;
    if(!pHandle || !(pMemPart = (ClMemPartT*)*pHandle) )
        return CL_ERR_INVALID_PARAMETER;
    clOsalMutexLock(&pMemPart->mutex);
    rc = memPartDelete(pMemPart->partId);
    clOsalMutexUnlock(&pMemPart->mutex);
    clOsalMutexDestroy(&pMemPart->mutex);
    free(pMemPart);
    *pHandle = 0;
    if(rc == ERROR)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("memPartDelete returned [%s]\n", strerror(errno)));
        return CL_ERR_UNSPECIFIED;
    }
    return CL_OK;
}
ClRcT clMsgFinalizeBlockInit(void)
{
    ClRcT rc;
    ClRcT retCode;

    rc = clOsalCondCreate(&gFinBlockCond);
    if(rc != CL_OK)
    {   
        clLogError("FIN", "BLOCK", "Failed to create a condtional variable. error code [0x%x].", rc);
        goto error_out;
    } 

    rc = clOsalMutexInit(&gFinBlockMutex);
    if(rc != CL_OK)
    {
        clLogError("FIN", "BLOCK", "Failed to create a mutex. error code [0x%x].", rc);
        goto error_out_1;
    } 

    rc = clMsgEventInitTimerStart();
    if(rc != CL_OK)
    {
        clLogError("FIN", "BLOCK", "Failed to start event initialize timer. error code [0x%x].", rc);
        goto error_out_2;
    }

    goto out;

error_out_2:
    retCode = clOsalMutexDestroy(&gFinBlockMutex);
    if(retCode != CL_OK)
        clLogError("MSG", "BLOCK", "Failed to destroy mutex. error code [0x%x].", retCode);
error_out_1:
    retCode = clOsalCondDelete(gFinBlockCond);
    if(retCode != CL_OK)
        clLogError("MSG", "BLOCK", "Failed to delete a conditional variable. error code [0x%x].", retCode);
error_out:
out:
    return rc;
}
ClRcT clMsgQueueInitialize(void)
{
    ClRcT rc, retCode;

    rc = clHandleDatabaseCreate(NULL, &gClMsgQDatabase);
    if(rc != CL_OK)
    {
        clLogError("QUE", "INI", "Failed to create a Queue Handle database. error code [0x%x].", rc);
        goto error_out;
    }

    rc = clOsalMutexInit(&gClLocalQsLock);
    if(rc != CL_OK)
    {
        clLogError("QUE", "INI", "Failed to initialize the \"all local queues' lock\". error code [0x%x].", rc);
        goto error_out_1;
    }

    rc = clOsalMutexInit(&gClQueueDbLock);
    if(rc != CL_OK)
    {
        clLogError("QUE", "INI", "Failed to initialize queue db mutex. error code [0x%x].", rc);
        goto error_out_2;
    }

    goto out;

error_out_2:
    retCode = clOsalMutexDestroy(&gClLocalQsLock);
    if(retCode != CL_OK)
        clLogError("QUE", "INI", "Failed to destroy the local queues' mutex. error code [0x%x].", retCode);
error_out_1:
    retCode = clHandleDatabaseDestroy(gClMsgQDatabase);
    if(retCode != CL_OK)
        clLogError("QUE", "INI", "Failed to delete the Queue Handle database. error code [0x%x].", retCode);
error_out:
out:
    return rc;
}
ClRcT
clLogUtilLibFinalize(ClBoolT  logLibInit)
{
    ClRcT  rc = CL_OK;
    /* Notify the thread to stop */
    rc = clOsalMutexLock(&gLogMutex);
    if( CL_OK != rc )
    {
        return rc;
    }
    gUtilLibInitialized = CL_FALSE;
    clLogDebugFilterFinalize();
    /* 
     * signalling to that guy to wake up
     */
    clOsalCondSignal(&gLogCond);
    clOsalMutexUnlock(&gLogMutex);
    /* Wait till that thread finishes its own job */
    clOsalTaskJoin(taskId);

    /*
     * This is hardcoded, have to find out the best way to solve this problem
     * once all the data have been flushed, log library will be finalized.
     */
    if( CL_TRUE == logLibInit )
    {	
    	clLogFinalize(1);
    }
    /*
     * just destroying provided, all initialed libraried will be
     * finalized by main EO function. 
     */
    clOsalCondDestroy(&gLogCond);
    clOsalMutexDestroy(&gLogMutex);
    return CL_OK;
}
Пример #13
0
/*
 * Called with the msg finalize lock held.
 */
static int safMsgFinalize(ClBoolT *pLockStatus)
{
    ClRcT  rc = CL_OK;
    if(pLockStatus && !*pLockStatus) 
        return CL_MSG_RC(CL_ERR_INVALID_STATE);

    CL_MSG_INIT_CHECK(rc);
    if( rc != CL_OK)
    {
         return rc;
    }    
   
    gClMsgInit = CL_FALSE;

    if(pLockStatus)
    {
        *pLockStatus = CL_FALSE;
        clOsalMutexUnlock(&gClMsgFinalizeLock);
    }

    clMsgFinalizeBlocker();

    rc = clMsgFinalizeBlockFin();
    if(rc != CL_OK)
        clLogError("MSG", "INI", "Failed to cleanup the msg-finalize blocker. error code [0x%x].", rc);

    clMsgDebugCliDeregister();

    clMsgCommIdlFinalize();

    /* Finalize the IDL generated code. */
    rc = clMsgCltClientTableDeregister();
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "Failed to deregister Client Table. error code [0x%x].", rc);

    rc = clMsgIdlClientTableDeregister();
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "Failed to deregister Server Table. error code [0x%x].", rc);

    clMsgIdlClientUninstall();

    rc = clMsgCltSrvClientTableDeregister();
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "Failed to deregister Client Server Table. error code [0x%x].", rc);

    clMsgCltSrvClientUninstall();

    /* Finalize cached ckpt for MSG queue & MSG queue group */
    rc = clMsgQCkptFinalize();
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "clMsgQCkptFinalize(): error code [0x%x].", rc);

    /* Finalize database for maintaining queues. */
    clMsgReceiverDatabaseFin();

    rc = clMsgQueueFinalize();
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "Failed to finalize queue databases. error code [0x%x].", rc);

    rc = clCpmNotificationCallbackUninstall(&gMsgNotificationHandle);
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "Failed to uninstall the notification callback function. error code [0x%x].", rc);

    rc = clOsalMutexDestroy(&gClGroupDbLock);
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "Failed to destroy the group db lock. error code [0x%x].", rc);

    rc = clHandleDatabaseDestroy(gMsgClientHandleDb);
    if(rc != CL_OK)
        clLogError("MSG", "FIN", "Failed to destroy the client handle database. error code [0x%x].", rc);

    return rc;
}
Пример #14
0
static ClRcT initializeAmf(void)
{
    ClRcT         rc = CL_OK; 
    ClRcT         retCode;
    ClIocPhysicalAddressT notificationForComp = { CL_IOC_BROADCAST_ADDRESS, 0};
    
    clLogCompName = (ClCharT*) "MSG"; /* Override generated eo name with a short name for our server */
    clAppConfigure(&clEoConfig,clEoBasicLibs,clEoClientLibs);
  
    clMsgRegisterWithCpm();
     
    if(gClMsgInit == CL_TRUE)
    {
        rc = CL_MSG_RC(CL_ERR_INITIALIZED);
        clLogError("MSG", "INI", "The Message Service is already initialized. error code [0x%x].", rc);
        goto error_out;
    }
    
    gLocalAddress = clIocLocalAddressGet();
    gLocalPortId = CL_IOC_MSG_PORT;

    /* Initializing a database to maintain client information */
    rc = clHandleDatabaseCreate((void (*)(void*))NULL, &gMsgClientHandleDb);
     
    if(rc != CL_OK)
    {
        clLogError("MSG", "INI", "Failed to initialize the handle database. error code [0x%x].", rc);
        goto error_out;
    }
    
    /* Initializing IDL for server to server and server to client communication. */
    rc = clMsgCommIdlInitialize();
    if(rc != CL_OK)
    {
        clLogError("MSG", "INI", "Failed to initialize the IDL. error code [0x%x].", rc);
        goto error_out_2;
    }
    
    /* Initializing a database for maintaining queues. */
    rc = clMsgQueueInitialize();
    if(rc != CL_OK)
    {
        clLogError("MSG", "INI", "Failed to initialize the queue databases. error code [0x%x].", rc);
        goto error_out_3;
    }
   
    rc = clMsgReceiverDatabaseInit();
    if(rc != CL_OK)
    {
        clLogError("MSG", "INI", "Failed to initialize \"receiver database\". error code [0x%x].", rc);
        goto error_out_4;
    }

    rc = clOsalMutexInit(&gClMsgFinalizeLock);
    CL_ASSERT(rc == CL_OK);
    
    rc = clOsalCondInit(&gClMsgFinalizeCond);
    CL_ASSERT(rc == CL_OK);

    /* Initializing the Group-Information */
    rc = clOsalMutexInit(&gClGroupDbLock);
    CL_ASSERT(rc == CL_OK);

    rc = clCpmNotificationCallbackInstall(notificationForComp, &clMsgNotificationReceiveCallback, NULL, &gMsgNotificationHandle);
    if(rc != CL_OK)
    {
        clLogError("MSG", "INI", "Failed to install the notification callback function. error code [0x%x].", rc);
        goto error_out_5;
    }
   
    /* Initializing the IDL generated code. */
    rc = clMsgIdlClientInstall();
    if(rc != CL_OK)
    {
        clLogError("MSG", "INI", "Failed to install Server Table. error code [0x%x].", rc);
        goto error_out_6;
    }

    rc = clMsgIdlClientTableRegister(CL_IOC_MSG_PORT);
    if(rc != CL_OK)
    {
        clLogError("MSG", "INI", "Failed to register Server Table. error code [0x%x].", rc);
        goto error_out_7;
    }

    rc = clMsgCltClientTableRegister(CL_IOC_MSG_PORT);
    if(rc != CL_OK)
    {
        clLogError("MSG", "INI", "Failed to register Client Table. error code [0x%x].", rc);
        goto error_out_8;
    }

    rc = clMsgCltSrvClientInstall();
    if(rc != CL_OK)
    {
        clLogError("MSG", "INI", "Failed to install Client Server Table. error code [0x%x].", rc);
        goto error_out_9;
    }
  
    rc = clMsgCltSrvClientTableRegister(CL_IOC_MSG_PORT);
    if(rc != CL_OK)
    {
        clLogError("MSG", "INI", "Failed to register Client Server Table. error code [0x%x].", rc);
        goto error_out_10;
    }

    rc = clMsgFinalizeBlockInit();
    if(rc != CL_OK)
    {
        clLogError("MSG", "INI", "Failed to initialize the msg-finalize blocker. error code [0x%x].", rc);
        goto error_out_11;
    }
   
    clMsgDebugCliRegister();

    rc = clOsalTaskCreateDetached("MsgCkptInitAsync", CL_OSAL_SCHED_OTHER, CL_OSAL_THREAD_PRI_NOT_APPLICABLE, 0,
                                 clMsgCachedCkptInitAsync, NULL);
    CL_ASSERT(rc == CL_OK);

    goto out;
error_out_11:
    retCode = clMsgCltSrvClientTableDeregister();
    if(retCode != CL_OK)
        clLogError("MSG", "INI", "Failed to deregister Client Table. error code [0x%x].", retCode);
error_out_10:
    retCode = clMsgCltSrvClientUninstall();
    if(retCode != CL_OK)
        clLogError("MSG", "INI", "Failed to destroy the just opened handle database. error code [0x%x].", retCode);
error_out_9:
    retCode = clMsgCltClientTableDeregister();
    if(retCode != CL_OK)
        clLogError("MSG", "INI", "Failed to deregister Client Table. error code [0x%x].", retCode);
error_out_8:
    retCode = clMsgIdlClientTableDeregister();
    if(retCode != CL_OK)
        clLogError("MSG", "INI", "Failed to deregister Server Table. error code [0x%x].", retCode);
error_out_7:
    retCode = clMsgIdlClientUninstall();
    if(retCode != CL_OK)
        clLogError("MSG", "INI", "Failed to destroy the just opened handle database. error code [0x%x].", retCode);
error_out_6:
    retCode = clCpmNotificationCallbackUninstall(&gMsgNotificationHandle);
    if(retCode != CL_OK)
        clLogError("MSG", "INI", "Failed to uninstall the notification callback function. error code [0x%x].", retCode);
error_out_5:
    retCode = clOsalMutexDestroy(&gClGroupDbLock);
    if(retCode != CL_OK)
        clLogError("MSG", "INI", "Failed to destroy the group db mutex. error code [0x%x].", retCode);

    retCode = clOsalCondDestroy(&gClMsgFinalizeCond);
    if(retCode != CL_OK)
        clLogError("MSG", "INI", "Failed to destroy the finalization condition. error code [0x%x].", retCode);

    retCode = clOsalMutexDestroy(&gClMsgFinalizeLock);
    if(retCode != CL_OK)
        clLogError("MSG", "INI", "Failed to destroy the finalization mutex. error code [0x%x].", retCode);

    clMsgReceiverDatabaseFin();

error_out_4:
    retCode = clMsgQueueFinalize();
    if(retCode != CL_OK)
        clLogError("MSG", "INI", "Failed to finalize the queue databases. error code [0x%x].", retCode);
error_out_3:
    clMsgCommIdlFinalize();
error_out_2:
    retCode = clHandleDatabaseDestroy(gMsgClientHandleDb);
    if(retCode != CL_OK)
        clLogError("MSG", "INI", "Failed to destroy the handle database. error code [0x%x].", retCode);
error_out:
out:
    return rc;  
    
}//end of intializeAmf
ClRcT clEoQueueCreate(ClEoQueueHandleT *pHandle,
                      ClIocPriorityT priority,
                      ClThreadPoolModeT mode,
                      ClInt32T maxThreads,
                      ClInt32T threadPriority,
                      ClEoJobCallBackT pJobHandler,
                      ClPtrT pUserData
                      )
{
    ClEoQueueT *pQueue =NULL;
    ClThreadPoolHandleT threadPool=0;
    ClRcT rc = CL_EO_RC(CL_ERR_INVALID_PARAMETER);

    if(pHandle == NULL)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Invalid parameter\n"));
        goto out;
    }

    if( priority >= CL_IOC_MAX_PRIORITIES )
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Invalid priority %d\n",priority));
        goto out;
    }

    rc = CL_EO_RC(CL_ERR_OP_NOT_PERMITTED);

    CL_EO_QUEUE_LOCK(&gClEoQueueMutex);
    if(gpClEoQueues[priority])
    {
        CL_EO_QUEUE_UNLOCK(&gClEoQueueMutex);
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Queue with priority:%d already active\n",priority));
        goto out;
    }
    CL_EO_QUEUE_UNLOCK(&gClEoQueueMutex);

    if(!threadPriority)
    {
        threadPriority = gClEoThreadPriorityMap[priority];
    }

    rc = CL_EO_RC(CL_ERR_NO_MEMORY);
#if 0
    pQueue = clHeapCalloc(1,sizeof(*pQueue));
    if(pQueue == NULL)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Error allocating memory\n"));
        goto out;
    }
#endif

    CL_JOB_LIST_INIT(&pQueue->queue);
    rc = clOsalMutexInit(&pQueue->mutex);
    CL_ASSERT(rc == CL_OK);
    rc = clOsalCondInit(&pQueue->cond);
    CL_ASSERT(rc == CL_OK);

    if(pJobHandler == NULL)
    {
        /*Default handler for jobs*/
        pJobHandler = clEoJobHandler;
    }

#if 0 /* GAS */
    rc = clThreadPoolCreate(&threadPool,(ClEoQueueHandleT)pQueue,
                            mode,maxThreads,threadPriority,pJobHandler,
                            pUserData);
#endif

    rc = clJobQueueInit(&gEoJobQueue, 0, maxThreads);

    if(rc != CL_OK)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Error in thread pool create.rc=0x%x\n",rc));
        goto out_free;
    }

#if 0
    pQueue->pThreadPool = (ClThreadPoolT*)threadPool;
    pQueue->priority = priority;
    CL_EO_QUEUE_LOCK(&gClEoQueueMutex);
    if(gpClEoQueues[priority])
    {
        /*Someone beat us. So back out*/
        CL_EO_QUEUE_UNLOCK(&gClEoQueueMutex);
        rc = CL_EO_RC(CL_ERR_OP_NOT_PERMITTED);
        clThreadPoolDelete((ClThreadPoolHandleT) threadPool);
        goto out_free;
    }
    pQueue->state = CL_EO_QUEUE_STATE_ACTIVE;
    gpClEoQueues[priority] = pQueue;
    CL_EO_QUEUE_UNLOCK(&gClEoQueueMutex);
    *pHandle = (ClEoQueueHandleT)pQueue;
#endif

    rc = CL_OK;
    goto out;

    out_free:
#if 0
    clOsalMutexDestroy(&pQueue->mutex);
    clOsalCondDestroy(&pQueue->cond);
    clHeapFree(pQueue);
#endif

    out:
    return rc;
}