Commit 6042e5f8 by bernhard-gatzhammer

Improved codestyle and removed return in void spinlock destroy.

EMBB-509
parent 5bc9ff94
...@@ -163,5 +163,4 @@ int embb_spin_unlock(embb_spinlock_t* spinlock) { ...@@ -163,5 +163,4 @@ int embb_spin_unlock(embb_spinlock_t* spinlock) {
void embb_spin_destroy(embb_spinlock_t* spinlock) { void embb_spin_destroy(embb_spinlock_t* spinlock) {
// for now, doing nothing here... in future, will call the respective // for now, doing nothing here... in future, will call the respective
// destroy function for atomics... // destroy function for atomics...
return EMBB_SUCCESS;
} }
...@@ -124,7 +124,7 @@ void SpinLockTest::PreSpinLockInc() { ...@@ -124,7 +124,7 @@ void SpinLockTest::PreSpinLockInc() {
} }
void SpinLockTest::TestSpinLockIncUseLock() { 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_); embb_spin_lock(&spinlock_);
counter_++; counter_++;
embb_spin_unlock(&spinlock_); embb_spin_unlock(&spinlock_);
...@@ -132,7 +132,7 @@ void SpinLockTest::TestSpinLockIncUseLock() { ...@@ -132,7 +132,7 @@ void SpinLockTest::TestSpinLockIncUseLock() {
} }
void SpinLockTest::TestSpinLockIncUseTryLock() { 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) {} while (embb_spin_try_lock(&spinlock_, 100) != EMBB_SUCCESS) {}
counter_++; counter_++;
embb_spin_unlock(&spinlock_); embb_spin_unlock(&spinlock_);
......
...@@ -89,6 +89,7 @@ class MutexTest : public partest::TestCase { ...@@ -89,6 +89,7 @@ class MutexTest : public partest::TestCase {
class SpinLockTest : public partest::TestCase { class SpinLockTest : public partest::TestCase {
public: public:
SpinLockTest(); SpinLockTest();
private: private:
/** /**
* Check that the try lock fails, when lock is already set. * Check that the try lock fails, when lock is already set.
......
...@@ -81,10 +81,9 @@ void Spinlock::Lock() { ...@@ -81,10 +81,9 @@ void Spinlock::Lock() {
bool Spinlock::TryLock(unsigned int number_spins) { bool Spinlock::TryLock(unsigned int number_spins) {
int status = embb_spin_try_lock(&spinlock_, number_spins); int status = embb_spin_try_lock(&spinlock_, number_spins);
if (status == EMBB_BUSY){ if (status == EMBB_BUSY) {
return false; return false;
} } else if (status != EMBB_SUCCESS) {
else if (status != EMBB_SUCCESS) {
EMBB_THROW(ErrorException, "Error while try-locking spinlock"); EMBB_THROW(ErrorException, "Error while try-locking spinlock");
} }
......
...@@ -227,7 +227,7 @@ number_threads_(partest::TestSuite::GetDefaultNumThreads()), ...@@ -227,7 +227,7 @@ number_threads_(partest::TestSuite::GetDefaultNumThreads()),
} }
void SpinLockTest::TestSpinlockCountLock() { void SpinLockTest::TestSpinlockCountLock() {
for (unsigned int i = 0; i != counter_iterations_; ++i){ for (unsigned int i = 0; i != counter_iterations_; ++i) {
spinlock_.Lock(); spinlock_.Lock();
counter_++; counter_++;
spinlock_.Unlock(); spinlock_.Unlock();
...@@ -235,7 +235,7 @@ void SpinLockTest::TestSpinlockCountLock() { ...@@ -235,7 +235,7 @@ void SpinLockTest::TestSpinlockCountLock() {
} }
void SpinLockTest::TestSpinlockCountLockTryLock() { void SpinLockTest::TestSpinlockCountLockTryLock() {
for (unsigned int i = 0; i != counter_iterations_; ++i){ for (unsigned int i = 0; i != counter_iterations_; ++i) {
while (!spinlock_.TryLock()) {} while (!spinlock_.TryLock()) {}
counter_++; counter_++;
spinlock_.Unlock(); spinlock_.Unlock();
......
...@@ -90,10 +90,10 @@ class MutexTest : public partest::TestCase { ...@@ -90,10 +90,10 @@ class MutexTest : public partest::TestCase {
}; };
class SpinLockTest : public partest::TestCase { class SpinLockTest : public partest::TestCase {
public: public:
SpinLockTest(); SpinLockTest();
private:
private:
/** /**
* Uses Spinlock to realize multi-threaded counting. * Uses Spinlock to realize multi-threaded counting.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment