953 |
|
|
954 |
# endif /* !MSWINCE */ |
# endif /* !MSWINCE */ |
955 |
|
|
956 |
|
/* |
957 |
|
* Run a function under GC control in a thread that was not created |
958 |
|
* through the gc routines. |
959 |
|
* (for example by a thrid party library that does a callback). |
960 |
|
*/ |
961 |
|
GC_API void * |
962 |
|
GC_run_thread(LPTHREAD_START_ROUTINE thread_func, LPVOID arg) |
963 |
|
{ |
964 |
|
LPVOID result; |
965 |
|
|
966 |
|
/* register the thread */ |
967 |
|
#if defined(GC_DLL) && !defined(CYGWIN32) |
968 |
|
/* we have nothing to do here because the thread is registered through DllMain */ |
969 |
|
#else |
970 |
|
GC_ASSERT(GC_thr_initialized); |
971 |
|
if (GC_main_thread != GetCurrentThreadId()) { |
972 |
|
GC_new_thread(); |
973 |
|
} /* o.w. we already did it during GC_thr_init(), called by GC_init() */ |
974 |
|
#endif |
975 |
|
result = thread_func(arg); |
976 |
|
|
977 |
|
/* unregister the thread */ |
978 |
|
#if defined(GC_DLL) && !defined(CYGWIN32) |
979 |
|
/* we have nothing to do here because the thread is will be unregistered */ |
980 |
|
/* through DllMain */ |
981 |
|
#else |
982 |
|
GC_delete_thread(GetCurrentThreadId()); |
983 |
|
#endif |
984 |
|
return result; |
985 |
|
} |
986 |
|
|
987 |
#endif /* GC_WIN32_THREADS */ |
#endif /* GC_WIN32_THREADS */ |