Added SILC Tls API for Thread-local storage. Added SilcTls
[silc.git] / lib / silcutil / tests / test_silcthread.c
index b2ec10d17cafc9244f45cad283e6908da294004f..19315701ad8697860d1ada1551d8aa1fbd9ea3b6 100644 (file)
@@ -6,11 +6,12 @@ SilcSchedule schedule;
 
 static void func(SilcSchedule schedule, void *context)
 {
-  SILC_LOG_DEBUG(("func: %d", (int)context));
+  silc_thread_tls_set(context);
+  SILC_LOG_DEBUG(("func: %d", (int)silc_thread_tls_get()));
   sleep(1);
 }
 
-static void compl(SilcSchedule schedule, void *context)
+SILC_TASK_CALLBACK(compl)
 {
   SILC_LOG_DEBUG(("completion: %d", (int)context));
   if ((int)context == 0xff)
@@ -46,13 +47,13 @@ int main(int argc, char **argv)
   tp = silc_thread_pool_alloc(NULL, 0, 2, FALSE);
   if (!tp)
     goto err;
-  for (i = 0; i < 4; i++) {
+  for (i = 0; i < 6; i++) {
     SILC_LOG_DEBUG(("Run thread %d", i + 1));
     if (!silc_thread_pool_run(tp, TRUE, NULL, func, (void *) i + 1,
                              compl, (void *)i + 1))
       goto err;
   }
-  sleep(4);
+  sleep(6);
   SILC_LOG_DEBUG(("Stop thread pool"));
   silc_thread_pool_free(tp, TRUE);