diff --git a/base_c/src/mutex.c b/base_c/src/mutex.c index 5c4a0c0..e3814e1 100644 --- a/base_c/src/mutex.c +++ b/base_c/src/mutex.c @@ -163,5 +163,4 @@ int embb_spin_unlock(embb_spinlock_t* spinlock) { void embb_spin_destroy(embb_spinlock_t* spinlock) { // for now, doing nothing here... in future, will call the respective // destroy function for atomics... - return EMBB_SUCCESS; } diff --git a/base_c/test/mutex_test.cc b/base_c/test/mutex_test.cc index e173385..4c045a1 100644 --- a/base_c/test/mutex_test.cc +++ b/base_c/test/mutex_test.cc @@ -124,7 +124,7 @@ void SpinLockTest::PreSpinLockInc() { } void SpinLockTest::TestSpinLockIncUseLock() { - for (unsigned int i = 0; i != counter_iterations_; ++i){ + for (unsigned int i = 0; i != counter_iterations_; ++i) { embb_spin_lock(&spinlock_); counter_++; embb_spin_unlock(&spinlock_); @@ -132,7 +132,7 @@ void SpinLockTest::TestSpinLockIncUseLock() { } void SpinLockTest::TestSpinLockIncUseTryLock() { - for (unsigned int i = 0; i != counter_iterations_; ++i){ + for (unsigned int i = 0; i != counter_iterations_; ++i) { while (embb_spin_try_lock(&spinlock_, 100) != EMBB_SUCCESS) {} counter_++; embb_spin_unlock(&spinlock_); diff --git a/base_c/test/mutex_test.h b/base_c/test/mutex_test.h index 0359d47..dfe5dda 100644 --- a/base_c/test/mutex_test.h +++ b/base_c/test/mutex_test.h @@ -89,6 +89,7 @@ class MutexTest : public partest::TestCase { class SpinLockTest : public partest::TestCase { public: SpinLockTest(); + private: /** * Check that the try lock fails, when lock is already set. diff --git a/base_cpp/src/mutex.cc b/base_cpp/src/mutex.cc index fd0c2e1..be387f1 100644 --- a/base_cpp/src/mutex.cc +++ b/base_cpp/src/mutex.cc @@ -81,10 +81,9 @@ void Spinlock::Lock() { bool Spinlock::TryLock(unsigned int number_spins) { int status = embb_spin_try_lock(&spinlock_, number_spins); - if (status == EMBB_BUSY){ + if (status == EMBB_BUSY) { return false; - } - else if (status != EMBB_SUCCESS) { + } else if (status != EMBB_SUCCESS) { EMBB_THROW(ErrorException, "Error while try-locking spinlock"); } diff --git a/base_cpp/test/mutex_test.cc b/base_cpp/test/mutex_test.cc index 571a4a2..b788c6d 100644 --- a/base_cpp/test/mutex_test.cc +++ b/base_cpp/test/mutex_test.cc @@ -227,7 +227,7 @@ number_threads_(partest::TestSuite::GetDefaultNumThreads()), } void SpinLockTest::TestSpinlockCountLock() { - for (unsigned int i = 0; i != counter_iterations_; ++i){ + for (unsigned int i = 0; i != counter_iterations_; ++i) { spinlock_.Lock(); counter_++; spinlock_.Unlock(); @@ -235,7 +235,7 @@ void SpinLockTest::TestSpinlockCountLock() { } void SpinLockTest::TestSpinlockCountLockTryLock() { - for (unsigned int i = 0; i != counter_iterations_; ++i){ + for (unsigned int i = 0; i != counter_iterations_; ++i) { while (!spinlock_.TryLock()) {} counter_++; spinlock_.Unlock(); diff --git a/base_cpp/test/mutex_test.h b/base_cpp/test/mutex_test.h index d301058..8f379e3 100644 --- a/base_cpp/test/mutex_test.h +++ b/base_cpp/test/mutex_test.h @@ -90,10 +90,10 @@ class MutexTest : public partest::TestCase { }; class SpinLockTest : public partest::TestCase { -public: + public: SpinLockTest(); -private: + private: /** * Uses Spinlock to realize multi-threaded counting. */