@@ -88,10 +88,13 @@ # define lrint(x) rint(x) #endif #if defined(OF_HAVE_THREADS) # import "tlskey.h" +# if defined(OF_AMIGAOS) && defined(OF_HAVE_SOCKETS) +# import "socket.h" +# endif static of_tlskey_t threadSelfKey; static OFThread *mainThread; static void @@ -111,10 +114,17 @@ of_thread_set_name( [name cStringWithEncoding: [OFLocale encoding]]); else of_thread_set_name(object_getClassName(thread)); +#if defined(OF_AMIGAOS) && defined(OF_HAVE_SOCKETS) + if (thread.supportsSockets) + if (!of_socket_init()) + @throw [OFInitializationFailedException + exceptionWithClass: thread.class]; +#endif + /* * Nasty workaround for thread implementations which can't return a * pointer on join, or don't have a way to exit a thread. */ if (setjmp(thread->_exitEnv) == 0) { @@ -128,10 +138,15 @@ [thread handleTermination]; objc_autoreleasePoolPop(thread->_pool); [OFAutoreleasePool of_handleThreadTermination]; + +#if defined(OF_AMIGAOS) && defined(OF_HAVE_SOCKETS) + if (thread.supportsSockets) + of_socket_deinit(); +#endif thread->_running = OF_THREAD_WAITING_FOR_JOIN; [thread release]; } @@ -463,10 +478,24 @@ @throw [OFThreadStillRunningException exceptionWithThread: self]; _attr.stackSize = stackSize; } + +- (bool)supportsSockets +{ + return _supportsSockets; +} + +- (void)setSupportsSockets: (bool)supportsSockets +{ + if (_running == OF_THREAD_RUNNING) + @throw [OFThreadStillRunningException + exceptionWithThread: self]; + + _supportsSockets = supportsSockets; +} - (void)dealloc { if (_running == OF_THREAD_RUNNING) @throw [OFThreadStillRunningException