X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=lib%2Fsilcutil%2Fsilcthread.c;h=3ada012c14e86c3c264c0f275a0476fbd1f2d523;hp=794259c78dc11eab00bd71d39679053c0dabc988;hb=c6bb9e5e82ae3a2d667e826b9bd979cbe72e1493;hpb=0f330f9f731f0659b210c29109a4272c7c7f5380 diff --git a/lib/silcutil/silcthread.c b/lib/silcutil/silcthread.c index 794259c7..3ada012c 100644 --- a/lib/silcutil/silcthread.c +++ b/lib/silcutil/silcthread.c @@ -19,6 +19,8 @@ #include "silc.h" +/***************************** Thread Pool API *****************************/ + /* Explanation of the thread pool execution. When new call is added to thread pool by calling silc_thread_pool_run @@ -572,3 +574,27 @@ void silc_thread_pool_purge(SilcThreadPool tp) silc_list_start(tp->threads); silc_mutex_unlock(tp->lock); } + +/*************************** Thread-local Storage ***************************/ + +void silc_thread_tls_set(void *context) +{ + SilcTls tls = silc_thread_get_tls(); + + if (!tls) { + /* Initialize Tls for this thread */ + tls = silc_thread_tls_init(); + if (!tls) + return; + } + + tls->thread_context = context; +} + +void *silc_thread_tls_get(void) +{ + SilcTls tls = silc_thread_get_tls(); + if (!tls) + return NULL; + return tls->thread_context; +}