5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2002 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
21 #include "silcincludes.h"
25 /* Thread structure for EPOC */
28 SilcThreadStart start_func;
33 /* The actual thread function */
35 TInt silc_thread_epoc_start(TAny *context)
37 SilcEpocThread thread = (SilcEpocThread)context;
39 thread->start_func(thread->context);
40 silc_thread_exit(NULL);
45 SilcThread silc_thread_create(SilcThreadStart start_func, void *context,
49 SilcEpocThread thread;
52 SILC_LOG_DEBUG(("Creating new thread"));
54 thread = silc_calloc(1, sizeof(*thread));
55 thread->start_func = start_func;
56 thread->context = context;
57 thread->waitable = waitable;
59 /* Create the thread */
60 /* XXX Unique name should be given for the thread */
61 thread->thread = new RThread();
62 ret = thread->thread->Create(NULL, silc_thread_epoc_start, 0, 0, 0,
63 (TAny *)thread, EOwnerProcess);
64 if (ret != KErrNone) {
65 SILC_LOG_ERROR(("Could not create new thread"));
66 delete thread->thread;
71 return (SilcThread)thread;
73 /* Call thread callback immediately */
74 (*start_func)(context);
79 void silc_thread_exit(void *exit_value)
86 SilcThread silc_thread_self(void)
96 bool silc_thread_wait(SilcThread thread, void **exit_value)