* in the threads. The thread pool manages the threads creation and
* destruction.
*
+ * The interface also provides routines for accessing the Thread-local
+ * storage (Tls) on all supported platforms.
+ *
***/
#ifndef SILCTHREAD_H
*
* A callback function of this type is given as argument to the
* silc_thread_pool_run. The `schedule' is the scheduler and the
- * `context' is the `run_context' or `completion_context' given as
- * argument to silc_thread_pool_run.
+ * `context' is the `run_context' given as argument to
+ * silc_thread_pool_run.
*
***/
typedef void (*SilcThreadPoolFunc)(SilcSchedule schedule, void *context);
* DESCRIPTION
*
* Allocate thread pool with at least `min_threads' and at most
- * `max_threads' many threads. If `stack' is non-NULL all memory is
- * allocated from the `stack'. If `start_min_threads' is TRUE this will
+ * `max_threads' many threads. If `start_min_threads' is TRUE this will
* start `min_threads' many threads immediately. Returns the thread
- * pool context or NULL on error.
+ * pool context or NULL on error. If `stack' is non-NULL memory is
+ * allocated from `stack'. When the thread pool is freed the memory
+ * is returned to `stack'.
*
* EXAMPLE
*
* SilcSchedule schedule,
* SilcThreadPoolFunc run,
* void *run_context,
- * SilcThreadPoolFunc completion,
+ * SilcTaskCallback completion,
* void *completion_context);
*
* DESCRIPTION
SilcSchedule schedule,
SilcThreadPoolFunc run,
void *run_context,
- SilcThreadPoolFunc completion,
+ SilcTaskCallback completion,
void *completion_context);
/****f* silcutil/SilcThreadAPI/silc_thread_pool_set_max_threads
void silc_thread_pool_set_max_threads(SilcThreadPool tp,
SilcUInt32 max_threads);
-/****f* silcutil/SilcThreadAPI/silc_thread_pool_num_max_threads
+/****f* silcutil/SilcThreadAPI/silc_thread_pool_get_max_threads
*
* SYNOPSIS
*
- * SilcUInt32 silc_thread_pool_num_max_threads(SilcThreadPool tp);
+ * SilcUInt32 silc_thread_pool_get_max_threads(SilcThreadPool tp);
*
* DESCRIPTION
*
* Returns the number of maximum threads to which the pool can grow.
*
***/
-SilcUInt32 silc_thread_pool_num_max_threads(SilcThreadPool tp);
+SilcUInt32 silc_thread_pool_get_max_threads(SilcThreadPool tp);
/****f* silcutil/SilcThreadAPI/silc_thread_pool_num_free_threads
*
***/
void silc_thread_pool_purge(SilcThreadPool tp);
+/****f* silcutil/SilcThreadAPI/silc_thread_tls_set
+ *
+ * SYNOPSIS
+ *
+ * void silc_thread_tls_set(void *context);
+ *
+ * DESCRIPTION
+ *
+ * Sets `context' into the Thread-local storage. Any previously set
+ * value will be replaced. This function may be called for the main
+ * thread also. This function may be called also if the program does
+ * not support threads.
+ *
+ * To retrieve the context from the Tls, call silc_thread_tls_get.
+ *
+ ***/
+void silc_thread_tls_set(void *context);
+
+/****f* silcutil/SilcThreadAPI/silc_thread_tls_get
+ *
+ * SYNOPSIS
+ *
+ * void *silc_thread_tls_get(void);
+ *
+ * DESCRIPTION
+ *
+ * Returns context from the Thread-local storage. If context has no been
+ * set for the current thread NULL will be returned.
+ *
+ ***/
+void *silc_thread_tls_get(void);
+
+#include "silcthread_i.h"
+
#endif