Beispiel #1
0
int threadpool_start(int n) {
    ThreadPool *tp = malloc(sizeof(ThreadPool));
    if (tp && ThreadPool_init(tp, n * 5, n) != 0) {
        free(tp);
    }
    return tp;
}
Beispiel #2
0
static
PyObject*
init(PyObject *self, PyObject *args)
{
    int capacity, numthreads;
    if ( !PyArg_ParseTuple(args, "ii", &capacity, &numthreads) ) {
        return NULL;
    }
    if ( ThreadPool_init(&threadpool, capacity, numthreads) ) {
        PyErr_SetString(PyExc_Exception, "can't initialize thread pool");
        return NULL;
    }
    initialized_flag = 1;
    Py_RETURN_NONE;
}
Beispiel #3
0
SLresult CEngine_Realize(void *self, SLboolean async)
{
    CEngine *thiz = (CEngine *) self;
    SLresult result;
#ifndef ANDROID
    // create the sync thread
    int err = pthread_create(&thiz->mSyncThread, (const pthread_attr_t *) NULL, sync_start, thiz);
    result = err_to_result(err);
    if (SL_RESULT_SUCCESS != result)
        return result;
#endif
    // initialize the thread pool for asynchronous operations
    result = ThreadPool_init(&thiz->mThreadPool, 0, 0);
    if (SL_RESULT_SUCCESS != result) {
        thiz->mEngine.mShutdown = SL_BOOLEAN_TRUE;
        (void) pthread_join(thiz->mSyncThread, (void **) NULL);
        return result;
    }
#ifdef USE_SDL
    SDL_open(&thiz->mEngine);
#endif
    return SL_RESULT_SUCCESS;
}