27 #if defined(USE_THREADS_POSIX) 28 # ifdef HAVE_PTHREAD_H 31 #elif defined(USE_THREADS_WIN32) 32 # ifdef HAVE_PROCESS_H 42 #if defined(USE_THREADS_POSIX) 44 struct curl_actual_call {
45 unsigned int (*func)(
void *);
49 static void *curl_thread_create_thunk(
void *arg)
51 struct curl_actual_call * ac = arg;
52 unsigned int (*func)(
void *) = ac->func;
53 void *real_arg = ac->arg;
62 curl_thread_t Curl_thread_create(
unsigned int (*func) (
void *),
void *arg)
64 curl_thread_t
t =
malloc(
sizeof(pthread_t));
65 struct curl_actual_call *ac =
malloc(
sizeof(
struct curl_actual_call));
72 if(pthread_create(t, NULL, curl_thread_create_thunk, ac) != 0)
80 return curl_thread_t_null;
83 void Curl_thread_destroy(curl_thread_t
hnd)
85 if(hnd != curl_thread_t_null) {
91 int Curl_thread_join(curl_thread_t *hnd)
93 int ret = (pthread_join(**hnd, NULL) == 0);
96 *hnd = curl_thread_t_null;
101 #elif defined(USE_THREADS_WIN32) 104 curl_thread_t Curl_thread_create(
unsigned int (CURL_STDCALL *func) (
void *),
109 t = CreateThread(NULL, 0, func, arg, 0, NULL);
111 t = (curl_thread_t)_beginthreadex(NULL, 0, func, arg, 0, NULL);
113 if((t == 0) || (t == LongToHandle(-1L))) {
115 DWORD gle = GetLastError();
116 errno = ((gle == ERROR_ACCESS_DENIED ||
117 gle == ERROR_NOT_ENOUGH_MEMORY) ?
120 return curl_thread_t_null;
125 void Curl_thread_destroy(curl_thread_t hnd)
130 int Curl_thread_join(curl_thread_t *hnd)
132 #if !defined(_WIN32_WINNT) || !defined(_WIN32_WINNT_VISTA) || \ 133 (_WIN32_WINNT < _WIN32_WINNT_VISTA) 134 int ret = (WaitForSingleObject(*hnd, INFINITE) == WAIT_OBJECT_0);
136 int ret = (WaitForSingleObjectEx(*hnd, INFINITE,
FALSE) == WAIT_OBJECT_0);
139 Curl_thread_destroy(*hnd);
141 *hnd = curl_thread_t_null;
geometry_msgs::TransformStamped t