diff options
Diffstat (limited to 'core/io/ip.cpp')
-rw-r--r-- | core/io/ip.cpp | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/core/io/ip.cpp b/core/io/ip.cpp index af534e4bb7..2143b84d15 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -71,7 +71,7 @@ struct _IP_ResolverPrivate { } Mutex mutex; - SemaphoreOld *sem; + Semaphore sem; Thread *thread; //Semaphore* semaphore; @@ -98,7 +98,7 @@ struct _IP_ResolverPrivate { while (!ipr->thread_abort) { - ipr->sem->wait(); + ipr->sem.wait(); MutexLock lock(ipr->mutex); ipr->resolve_queues(); @@ -148,7 +148,7 @@ IP::ResolverID IP::resolve_hostname_queue_item(const String &p_hostname, IP::Typ resolver->queue[id].response = IP_Address(); resolver->queue[id].status = IP::RESOLVER_STATUS_WAITING; if (resolver->thread) - resolver->sem->post(); + resolver->sem.post(); else resolver->resolve_queues(); } @@ -300,23 +300,13 @@ IP::IP() { singleton = this; resolver = memnew(_IP_ResolverPrivate); - resolver->sem = NULL; #ifndef NO_THREADS - resolver->sem = SemaphoreOld::create(); - if (resolver->sem) { - resolver->thread_abort = false; + resolver->thread_abort = false; - resolver->thread = Thread::create(_IP_ResolverPrivate::_thread_function, resolver); - - if (!resolver->thread) - memdelete(resolver->sem); //wtf - } else { - resolver->thread = NULL; - } + resolver->thread = Thread::create(_IP_ResolverPrivate::_thread_function, resolver); #else - resolver->sem = NULL; resolver->thread = NULL; #endif } @@ -326,10 +316,9 @@ IP::~IP() { #ifndef NO_THREADS if (resolver->thread) { resolver->thread_abort = true; - resolver->sem->post(); + resolver->sem.post(); Thread::wait_to_finish(resolver->thread); memdelete(resolver->thread); - memdelete(resolver->sem); } #endif |