diff options
author | Matt Caswell <matt@openssl.org> | 2015-09-16 17:01:58 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-11-20 23:33:46 +0000 |
commit | 0ff2b9ac0b8b9cd62e20cd65bf4922b34f57a8c1 (patch) | |
tree | 4bbf15099168a631bf984aad132b301fbfcb2a69 /crypto/async/arch/async_posix.c | |
parent | f4da39d200a8c2068595b8d5bd5efb78af4224e1 (diff) | |
download | openssl-0ff2b9ac0b8b9cd62e20cd65bf4922b34f57a8c1.zip openssl-0ff2b9ac0b8b9cd62e20cd65bf4922b34f57a8c1.tar.gz openssl-0ff2b9ac0b8b9cd62e20cd65bf4922b34f57a8c1.tar.bz2 |
Implement local thread pools
Implement the ASYNC_JOB as a local thread pool. Remove the API support
for global pools.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'crypto/async/arch/async_posix.c')
-rw-r--r-- | crypto/async/arch/async_posix.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/crypto/async/arch/async_posix.c b/crypto/async/arch/async_posix.c index 8474ea4..d85a537 100644 --- a/crypto/async/arch/async_posix.c +++ b/crypto/async/arch/async_posix.c @@ -65,6 +65,10 @@ __thread ASYNC_CTX *sysvctx; #define STACKSIZE 32768 +__thread size_t pool_max_size = 0; +__thread size_t pool_curr_size = 0; +__thread STACK_OF(ASYNC_JOB) *pool = NULL; + int ASYNC_FIBRE_init(ASYNC_FIBRE *fibre) { void *stack = NULL; @@ -111,4 +115,42 @@ int async_read1(int fd, void *buf) return 0; } +STACK_OF(ASYNC_JOB) *async_get_pool(void) +{ + return pool; +} + +void async_set_pool(STACK_OF(ASYNC_JOB) *poolin, size_t curr_size, + size_t max_size) +{ + pool = poolin; + pool_curr_size = curr_size; + pool_max_size = max_size; +} + +void async_increment_pool_size(void) +{ + pool_curr_size++; +} + +void async_release_job_to_pool(ASYNC_JOB *job) +{ + sk_ASYNC_JOB_push(pool, job); +} + +size_t async_pool_max_size(void) +{ + return pool_max_size; +} + +void async_release_pool(void) +{ + sk_ASYNC_JOB_free(pool); +} + +int async_pool_can_grow(void) +{ + return (pool_max_size == 0) || (pool_curr_size < pool_max_size); +} + #endif |