From: David Antler Date: Wed, 9 Mar 2016 19:44:26 +0000 (-0800) Subject: Remove ca_mutex_trylock and associated unit test X-Git-Tag: 1.2.0+RC1~545 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cee9051cc36a427aba55a886e800dde8b83063e2;p=platform%2Fupstream%2Fiotivity.git Remove ca_mutex_trylock and associated unit test ca_mutex_trylock is not used anywhere. Implementation of this function presents challenges for porting to additional platforms where an easily-wrappable implementation might not be available, such as on Windows. Change-Id: I7727c5f9a6c97a53dda15007cdfd74043ab03a7b Signed-off-by: David Antler Reviewed-on: https://gerrit.iotivity.org/gerrit/5645 Tested-by: jenkins-iotivity Reviewed-by: Jon A. Cruz --- diff --git a/resource/csdk/connectivity/common/inc/camutex.h b/resource/csdk/connectivity/common/inc/camutex.h index 29d42d8..5a1c00f 100644 --- a/resource/csdk/connectivity/common/inc/camutex.h +++ b/resource/csdk/connectivity/common/inc/camutex.h @@ -64,16 +64,6 @@ ca_mutex ca_mutex_new(void); void ca_mutex_lock(ca_mutex mutex); /** - * Checks if the mutex can be locked. - * - * @param mutex The mutex to be locked. - * - * @return true if the mutex is not locked currently, otherwise false. - * - */ -bool ca_mutex_trylock(ca_mutex mutex); - -/** * Unlock the mutex. * * @param mutex The mutex to be unlocked. diff --git a/resource/csdk/connectivity/common/src/camutex_noop.c b/resource/csdk/connectivity/common/src/camutex_noop.c index 2250cb3..d725980 100644 --- a/resource/csdk/connectivity/common/src/camutex_noop.c +++ b/resource/csdk/connectivity/common/src/camutex_noop.c @@ -70,11 +70,6 @@ void ca_mutex_lock(ca_mutex mutex) return; } -bool ca_mutex_trylock(ca_mutex mutex) -{ - return true; -} - void ca_mutex_unlock(ca_mutex mutex) { return; diff --git a/resource/csdk/connectivity/common/src/camutex_pthreads.c b/resource/csdk/connectivity/common/src/camutex_pthreads.c index bc0dc28..834886c 100644 --- a/resource/csdk/connectivity/common/src/camutex_pthreads.c +++ b/resource/csdk/connectivity/common/src/camutex_pthreads.c @@ -152,37 +152,6 @@ void ca_mutex_lock(ca_mutex mutex) } } -bool ca_mutex_trylock(ca_mutex mutex) -{ - if (NULL == mutex) - { - OIC_LOG_V(ERROR, TAG, "%s Invalid mutex !", __func__); - return false; - } - - bool bRet = false; - - ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex; - - int result = pthread_mutex_trylock(&mutexInfo->mutex); - - switch (result) - { - case 0: - // Success - bRet = true; - break; - case EINVAL: - OIC_LOG_V(ERROR, TAG, "%s: Invalid mutex !", __func__); - break; - case EBUSY: - default: - break; - } - - return bRet; -} - void ca_mutex_unlock(ca_mutex mutex) { ca_mutex_internal *mutexInfo = (ca_mutex_internal*) mutex; diff --git a/resource/csdk/connectivity/test/camutex_tests.cpp b/resource/csdk/connectivity/test/camutex_tests.cpp index 24fcf06..1c3f34e 100644 --- a/resource/csdk/connectivity/test/camutex_tests.cpp +++ b/resource/csdk/connectivity/test/camutex_tests.cpp @@ -87,30 +87,6 @@ TEST(MutexTests, TC_01_CREATE) } } -TEST(MutexTests, TC_02_TRY_LOCK) -{ - ca_mutex mymutex = ca_mutex_new(); - - EXPECT_TRUE(mymutex != NULL); - if (mymutex != NULL) - { - EXPECT_TRUE(ca_mutex_trylock(mymutex)); // acquire it - - ca_mutex_unlock(mymutex); // release it - - ca_mutex_lock(mymutex); // acquire it - - EXPECT_FALSE(ca_mutex_trylock(mymutex)); // he should be lock - - EXPECT_FALSE(ca_mutex_trylock(NULL)); - - ca_mutex_unlock(mymutex); // release it - ca_mutex_free(mymutex); - - EXPECT_FALSE(ca_mutex_trylock(NULL)); - } -} - typedef struct _tagFunc1 { ca_mutex mutex;