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) {
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;
}
......@@ -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_);
......
......@@ -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.
......
......@@ -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");
}
......
......@@ -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();
......
......@@ -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.
*/
......
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