// here.
std::this_thread::sleep_for(std::chrono::seconds(1));
- mutex.acquire();
+ mutex.lock();
n_running--;
- mutex.release();
+ mutex.unlock();
}
n_max_running = 0;
// force all tasks to wait until we are done starting
- mutex.acquire();
+ mutex.lock();
for (unsigned int t = 0; t < 10; ++t)
tg += Threads::new_task(a_task);
// now let the tasks run
- mutex.release();
+ mutex.unlock();
tg.join_all();
}
AssertThrow(exists == true, ExcInternalError());
// wait for the barrier to clear
- m.acquire();
- m.release();
+ m.lock();
+ m.unlock();
// at this point, the tls object should have been cleared and should
// be back at its original value
const unsigned int N = 10;
Threads::Mutex m[N];
- // start N threads with mutices locked
+ // start N threads with mutexes locked
Threads::ThreadGroup<> tg;
for (unsigned int i = 0; i < N; ++i)
{
- m[i].acquire();
+ m[i].lock();
tg += Threads::new_thread(execute, m[i]);
}
// let threads work through their first part
std::this_thread::sleep_for(std::chrono::seconds(3));
- // then reset the thread local object and release the mutices so the
+ // then reset the thread local object and release the mutexes so the
// threads can actually run to an end
tls_data.clear();
for (unsigned int i = 0; i < N; ++i)
- m[i].release();
+ m[i].unlock();
// now make sure the threads all finish
tg.join_all();
AssertThrow(exists == true, ExcInternalError());
// wait for the barrier to clear
- m.acquire();
- m.release();
+ m.lock();
+ m.unlock();
// at this point, the tls object should have been cleared and should
// be back at its original value
const unsigned int N = 10;
Threads::Mutex m[N];
- // start N threads with mutices locked
+ // start N threads with mutexes locked
Threads::ThreadGroup<> tg;
for (unsigned int i = 0; i < N; ++i)
{
- m[i].acquire();
+ m[i].lock();
tg += Threads::new_thread(execute, m[i]);
}
// let threads work through their first part
std::this_thread::sleep_for(std::chrono::seconds(3));
- // then reset the thread local object and release the mutices so the
+ // then reset the thread local object and release the mutexes so the
// threads can actually run to an end
tls_data.clear();
for (unsigned int i = 0; i < N; ++i)
- m[i].release();
+ m[i].unlock();
// now make sure the threads all finish
tg.join_all();
// wait for the mutex to make sure the main
// thread has already moved on. we can immediately
// release the mutex again.
- mutex.acquire();
- mutex.release();
+ mutex.lock();
+ mutex.unlock();
deallog << "OK." << std::endl;
spin_lock = 1;
}
{
initlog();
- mutex.acquire();
+ mutex.lock();
// start and abandon the
// thread. because we hold the
// lock, the started task can not
std::this_thread::sleep_for(std::chrono::seconds(1));
// let abandoned thread continue
- mutex.release();
+ mutex.unlock();
// wait for thread to finish
while (spin_lock == 0)
// mutex. release the mutex again at the end of this function since
// mutices can only be released on the same thread as they are
// acquired on.
- mutex.acquire();
+ mutex.lock();
deallog << "OK." << std::endl;
spin_lock = 1;
- mutex.release();
+ mutex.unlock();
return 42;
}
{
initlog();
- mutex.acquire();
+ mutex.lock();
{
Threads::new_thread(worker);
}
p[i] = 0;
// make sure the worker thread can actually start
- mutex.release();
+ mutex.unlock();
// wait for the worker thread to do its work
while (spin_lock == 0)