int ASYNC_init_thread(size_t max_size, size_t init_size)
{
    async_pool *pool;
    size_t curr_size = 0;
    if (init_size > max_size) {
        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_INVALID_POOL_SIZE);
        return 0;
    }
    if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) {
        return 0;
    }
    if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC)) {
        return 0;
    }
    pool = OPENSSL_zalloc(sizeof *pool);
    if (pool == NULL) {
        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
        return 0;
    }
    pool->jobs = sk_ASYNC_JOB_new_null();
    if (pool->jobs == NULL) {
        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);
        OPENSSL_free(pool);
        return 0;
    }
    pool->max_size = max_size;
    while (init_size--) {
        ASYNC_JOB *job;
        job = async_job_new();
        if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {
            async_job_free(job);
            break;
        }
        job->funcargs = NULL;
        sk_ASYNC_JOB_push(pool->jobs, job);
        curr_size++;
    }
    pool->curr_size = curr_size;
    if (!CRYPTO_THREAD_set_local(&poolkey, pool)) {
        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);
        goto err;
    }
    return 1;
err:
    async_free_pool_internal(pool);
    return 0;
}
['static ASYNC_JOB *async_get_pool_job(void) {\n    ASYNC_JOB *job;\n    async_pool *pool;\n    pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey);\n    if (pool == NULL) {\n        if (ASYNC_init_thread(0, 0) == 0)\n            return NULL;\n        pool = (async_pool *)CRYPTO_THREAD_get_local(&poolkey);\n    }\n    job = sk_ASYNC_JOB_pop(pool->jobs);\n    if (job == NULL) {\n        if ((pool->max_size != 0) && (pool->curr_size >= pool->max_size))\n            return NULL;\n        job = async_job_new();\n        if (job != NULL) {\n            if (! async_fibre_makecontext(&job->fibrectx)) {\n                async_job_free(job);\n                return NULL;\n            }\n            pool->curr_size++;\n        }\n    }\n    return job;\n}', 'int ASYNC_init_thread(size_t max_size, size_t init_size)\n{\n    async_pool *pool;\n    size_t curr_size = 0;\n    if (init_size > max_size) {\n        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_INVALID_POOL_SIZE);\n        return 0;\n    }\n    if (!OPENSSL_init_crypto(OPENSSL_INIT_ASYNC, NULL)) {\n        return 0;\n    }\n    if (!ossl_init_thread_start(OPENSSL_INIT_THREAD_ASYNC)) {\n        return 0;\n    }\n    pool = OPENSSL_zalloc(sizeof *pool);\n    if (pool == NULL) {\n        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);\n        return 0;\n    }\n    pool->jobs = sk_ASYNC_JOB_new_null();\n    if (pool->jobs == NULL) {\n        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ERR_R_MALLOC_FAILURE);\n        OPENSSL_free(pool);\n        return 0;\n    }\n    pool->max_size = max_size;\n    while (init_size--) {\n        ASYNC_JOB *job;\n        job = async_job_new();\n        if (job == NULL || !async_fibre_makecontext(&job->fibrectx)) {\n            async_job_free(job);\n            break;\n        }\n        job->funcargs = NULL;\n        sk_ASYNC_JOB_push(pool->jobs, job);\n        curr_size++;\n    }\n    pool->curr_size = curr_size;\n    if (!CRYPTO_THREAD_set_local(&poolkey, pool)) {\n        ASYNCerr(ASYNC_F_ASYNC_INIT_THREAD, ASYNC_R_FAILED_TO_SET_POOL);\n        goto err;\n    }\n    return 1;\nerr:\n    async_free_pool_internal(pool);\n    return 0;\n}']