#include "include/rados/librados.hpp"
#include "include/Context.h"
#include "common/ceph_context.h"
-#include "common/Mutex.h"
+#include "common/ceph_mutex.h"
#include "common/Cond.h"
#include "include/utime.h"
#include "global/global_context.h"
//Writer functions
Writer::Writer(OmapBench *omap_bench) : ob(omap_bench) {
stringstream name;
- ob->data_lock.Lock();
+ ob->data_lock.lock();
name << omap_bench->prefix << ++(ob->data.started_ops);
- ob->data_lock.Unlock();
+ ob->data_lock.unlock();
oid = name.str();
}
void Writer::start_time() {
void OmapBench::aio_is_safe(rados_completion_t c, void *arg) {
AioWriter *aiow = reinterpret_cast<AioWriter *>(arg);
aiow->stop_time();
- Mutex * data_lock = &aiow->ob->data_lock;
- Mutex * thread_is_free_lock = &aiow->ob->thread_is_free_lock;
- Cond * thread_is_free = &aiow->ob->thread_is_free;
+ ceph::mutex * data_lock = &aiow->ob->data_lock;
+ ceph::mutex * thread_is_free_lock = &aiow->ob->thread_is_free_lock;
+ ceph::condition_variable* thread_is_free = &aiow->ob->thread_is_free;
int &busythreads_count = aiow->ob->busythreads_count;
o_bench_data &data = aiow->ob->data;
int INCREMENT = aiow->ob->increment;
}
double time = aiow->get_time();
delete aiow;
- data_lock->Lock();
+ data_lock->lock();
data.avg_latency = (data.avg_latency * data.completed_ops + time)
/ (data.completed_ops + 1);
data.completed_ops++;
data.mode.first = time/INCREMENT;
data.mode.second = data.freq_map[time/INCREMENT];
}
- data_lock->Unlock();
+ data_lock->unlock();
- thread_is_free_lock->Lock();
+ thread_is_free_lock->lock();
busythreads_count--;
- thread_is_free->Signal();
- thread_is_free_lock->Unlock();
+ thread_is_free->notify_all();
+ thread_is_free_lock->unlock();
}
string OmapBench::random_string(int len) {
comp = NULL;
AioWriter *this_aio_writer;
- Mutex::Locker l(thread_is_free_lock);
+ std::unique_lock l{thread_is_free_lock};
for (int i = 0; i < objects; i++) {
ceph_assert(busythreads_count <= threads);
//wait for a writer to be free
if (busythreads_count == threads) {
- int err = thread_is_free.Wait(thread_is_free_lock);
+ thread_is_free.wait(l);
ceph_assert(busythreads_count < threads);
- if (err < 0) {
- return err;
- }
}
//set up the write
return err;
}
}
- while(busythreads_count > 0) {
- thread_is_free.Wait(thread_is_free_lock);
- }
-
+ thread_is_free.wait(l, [this] { return busythreads_count <= 0;});
return 0;
}
#ifndef OMAP_BENCH_HPP_
#define OMAP_BENCH_HPP_
-#include "common/Mutex.h"
+#include "common/ceph_mutex.h"
#include "common/Cond.h"
#include "include/rados/librados.hpp"
#include <string>
omap_generator_t omap_generator;
//aio things
- Cond thread_is_free;
- Mutex thread_is_free_lock;
- Mutex data_lock;
+ ceph::condition_variable thread_is_free;
+ ceph::mutex thread_is_free_lock =
+ ceph::make_mutex("OmapBench::thread_is_free_lock");
+ ceph::mutex data_lock =
+ ceph::make_mutex("OmapBench::data_lock");
int busythreads_count;
librados::callback_t comp;
librados::callback_t safe;
OmapBench()
: test(&OmapBench::test_write_objects_in_parallel),
omap_generator(generate_uniform_omap),
- thread_is_free_lock("OmapBench::thread_is_free_lock"),
- data_lock("OmapBench::data_lock"),
busythreads_count(0),
comp(NULL), safe(aio_is_safe),
pool_name("rbd"),