Use the system call name as parameter to system_error
authorMikko Rasa <tdb@tdb.fi>
Tue, 23 Apr 2013 13:42:10 +0000 (16:42 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 23 Apr 2013 13:42:10 +0000 (16:42 +0300)
source/core/mutex.cpp
source/core/semaphore.cpp

index e1657c9f88c5d32c712b1d362c4cfbb9c8529b8d..4f830c5965fd3da0bbf684e24ab5c40e6fdfc9a7 100644 (file)
@@ -33,7 +33,7 @@ void Mutex::lock()
        EnterCriticalSection(&priv->crit);
 #else
        if(int err = pthread_mutex_lock(&priv->mutex))
-               throw system_error("Mutex::lock", err);
+               throw system_error("pthread_mutex_lock", err);
 #endif
 }
 
@@ -44,7 +44,7 @@ bool Mutex::trylock()
 #else
        int err = pthread_mutex_trylock(&priv->mutex);
        if(err && err!=EBUSY)
-               throw system_error("Mutex::trylock", err);
+               throw system_error("pthread_mutex_trylock", err);
        return !err;
 #endif
 }
@@ -55,7 +55,7 @@ void Mutex::unlock()
        LeaveCriticalSection(&priv->crit);
 #else
        if(int err = pthread_mutex_unlock(&priv->mutex))
-               throw system_error("Mutex::unlock", err);
+               throw system_error("pthread_mutex_unlock", err);
 #endif
 }
 
index 8fa1be90f7c7e234abde3e74409bfb916acbffb9..06e8435c3a34212599a8ead8817d28073c4c26cc 100644 (file)
@@ -53,13 +53,13 @@ void Semaphore::signal()
 {
 #ifdef WIN32
        if(!ReleaseSemaphore(priv->handle, 1, 0))
-               throw system_error("Semaphore::signal");
+               throw system_error("ReleaseSemaphore");
 #else
        MutexLock mlock(priv->mutex);
        if(priv->count<priv->limit)
                ++priv->count;
        if(int err = pthread_cond_signal(&priv->cond))
-               throw system_error("Semaphore::signal", err);
+               throw system_error("pthread_cond_signal", err);
 #endif
 }
 
@@ -68,12 +68,12 @@ void Semaphore::wait()
 #ifdef WIN32
        DWORD ret = WaitForSingleObject(priv->handle, INFINITE);
        if(ret==WAIT_FAILED)
-               throw system_error("Semaphore::wait");
+               throw system_error("WaitForSingleObject");
 #else
        MutexLock mlock(priv->mutex);
        while(!priv->count)
                if(int err = pthread_cond_wait(&priv->cond, &priv->mutex.priv->mutex))
-                       throw system_error("Semaphore::wait", err);
+                       throw system_error("pthread_cond_wait", err);
        --priv->count;
 #endif
 }
@@ -83,14 +83,14 @@ bool Semaphore::wait(const Time::TimeDelta &d)
 #ifdef WIN32
        DWORD ret = WaitForSingleObject(priv->handle, (DWORD)(d/Time::usec));
        if(ret==WAIT_FAILED)
-               throw system_error("Semaphore::wait");
+               throw system_error("WaitForSingleObject");
        return ret==WAIT_OBJECT_0;
 #else
        timespec timeout = Time::rawtime_to_timespec((Time::now()+d).raw());
 
        int err = pthread_cond_timedwait(&priv->cond, &priv->mutex.priv->mutex, &timeout);
        if(err && err!=ETIMEDOUT)
-               throw system_error("Semaphore::wait", err);
+               throw system_error("pthread_cond_timedwait", err);
        return err==0;
 #endif
 }