TutThreadCreateVa create a thread (va_list version)
T_THREAD TutThreadCreateVa(thread_func
,thread_arg
,var_arg_list
) T_THREAD_FUNCthread_func
; T_PTRthread_arg
; va_listvar_arg_list
;
thread_func
function to call from the new thread
thread_arg
argument to pass to thread_func
var_arg_list
argument list
Thread handle if successful, T_INVALID_THREAD otherwise.
If TutThreadCreateVa fails, it returns T_INVALID_THREAD and sets the global SmartSockets error number to one of:
TutThreadCreateVa is the non-varargs version of TutThreadCreate. (TutThreadCreate actually calls TutThreadCreateVa.) TutThreadCreateVa can be used to implement a varargs function.
In the C language, a varargs function (one that takes a variable number of arguments) cannot call another varargs function with the original arguments. A varargs function usually calls a helper function that takes a fixed number of arguments, with the last argument usually of type va_list. TutThreadCreateVa is TutThreadCreate’s helper function.
Threads created by TutThreadCreate or TutThreadCreateVa should always be exited with a call to TutThreadExit or by returning from thread_func
, which implicitly calls TutThreadExit for the thread.
TutThreadCreate, TutThreadExit
This example implements a minimal replacement for TutThreadCreate (primarily omitting error checking):
T_THREAD my_thread_create(T_THREAD_FUNC thread_func, T_PTR thread_arg, ...) { va_list var_arg_list; T_THREAD result; va_start(var_arg_list, thread_arg); result = TutThreadCreateVa(thread_func, thread_arg, var_arg_list); va_end(var_arg_list); return result; }
TIBCO SmartSockets™ Utilities Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |