Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2001 - 2007 Pekka Riikonen
+ Copyright (C) 2001 - 2008 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
*/
-/****h* silcutil/SILC Thread Interface
+/****h* silcutil/Thread Interface
*
* DESCRIPTION
*
* 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
/* Prototypes */
-/****s* silcutil/SilcThreadAPI/SilcThread
+/****s* silcutil/SilcThread
*
* NAME
*
***/
typedef void *SilcThread;
-/****f* silcutil/SilcThreadAPI/SilcThreadStart
+/****f* silcutil/SilcThreadStart
*
* SYNOPSIS
*
***/
typedef void *(*SilcThreadStart)(void *context);
-/****f* silcutil/SilcThreadAPI/silc_thread_create
+/****f* silcutil/silc_thread_create
*
* SYNOPSIS
*
SilcThread silc_thread_create(SilcThreadStart start_func, void *context,
SilcBool waitable);
-/****f* silcutil/SilcThreadAPI/silc_thread_exit
+/****f* silcutil/silc_thread_exit
*
* SYNOPSIS
*
***/
void silc_thread_exit(void *exit_value);
-/****f* silcutil/SilcThreadAPI/silc_thread_self
+/****f* silcutil/silc_thread_self
*
* SYNOPSIS
*
***/
SilcThread silc_thread_self(void);
-/****f* silcutil/SilcThreadAPI/silc_thread_wait
+/****f* silcutil/silc_thread_wait
*
* SYNOPSIS
*
***/
SilcBool silc_thread_wait(SilcThread thread, void **exit_value);
-/****f* silcutil/SilcThreadAPI/silc_thread_yield
+/****f* silcutil/silc_thread_yield
*
* SYNOPSIS
*
***/
void silc_thread_yield(void);
-/****s* silcutil/SilcThreadAPI/SilcThreadPool
+/****s* silcutil/SilcThreadPool
*
* NAME
*
***/
typedef struct SilcThreadPoolStruct *SilcThreadPool;
-/****f* silcutil/SilcThreadAPI/SilcThreadPoolFunc
+/****f* silcutil/SilcThreadPoolFunc
*
* SYNOPSIS
*
***/
typedef void (*SilcThreadPoolFunc)(SilcSchedule schedule, void *context);
-/****f* silcutil/SilcThreadAPI/silc_thread_pool_alloc
+/****f* silcutil/silc_thread_pool_alloc
*
* SYNOPSIS
*
SilcUInt32 max_threads,
SilcBool start_min_threads);
-/****f* silcutil/SilcThreadAPI/silc_thread_pool_free
+/****f* silcutil/silc_thread_pool_free
*
* SYNOPSIS
*
***/
void silc_thread_pool_free(SilcThreadPool tp, SilcBool wait_unfinished);
-/****f* silcutil/SilcThreadAPI/silc_thread_pool_run
+/****f* silcutil/silc_thread_pool_run
*
* SYNOPSIS
*
SilcTaskCallback completion,
void *completion_context);
-/****f* silcutil/SilcThreadAPI/silc_thread_pool_set_max_threads
+/****f* silcutil/silc_thread_pool_set_max_threads
*
* SYNOPSIS
*
void silc_thread_pool_set_max_threads(SilcThreadPool tp,
SilcUInt32 max_threads);
-/****f* silcutil/SilcThreadAPI/silc_thread_pool_get_max_threads
+/****f* silcutil/silc_thread_pool_get_max_threads
*
* SYNOPSIS
*
***/
SilcUInt32 silc_thread_pool_get_max_threads(SilcThreadPool tp);
-/****f* silcutil/SilcThreadAPI/silc_thread_pool_num_free_threads
+/****f* silcutil/silc_thread_pool_num_free_threads
*
* SYNOPSIS
*
***/
SilcUInt32 silc_thread_pool_num_free_threads(SilcThreadPool tp);
-/****f* silcutil/SilcThreadAPI/silc_thread_pool_purge
+/****f* silcutil/silc_thread_pool_purge
*
* SYNOPSIS
*
***/
void silc_thread_pool_purge(SilcThreadPool tp);
+/****f* silcutil/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/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