#include "common/Finisher.h"
#include "os/filestore/FileJournal.h"
#include "include/Context.h"
-#include "common/Mutex.h"
+#include "common/ceph_mutex.h"
#include "common/safe_io.h"
#include "os/filestore/JournalingObjectStore.h"
Finisher *finisher;
-Cond sync_cond;
+ceph::condition_variable sync_cond;
char path[200];
uuid_d fsid;
struct test_info {
};
// ----
-Cond cond;
-Mutex wait_lock("lock");
+ceph::condition_variable cond;
+ceph::mutex wait_lock = ceph::make_mutex("lock");
bool done;
void wait()
{
- wait_lock.Lock();
- while (!done)
- cond.Wait(wait_lock);
- wait_lock.Unlock();
+ std::unique_lock l{wait_lock};
+ cond.wait(l, [] { return done; });
}
// ----
class C_Sync {
public:
- Cond cond;
- Mutex lock;
- bool done;
+ ceph::condition_variable cond;
+ ceph::mutex lock = ceph::make_mutex("C_Sync::lock");
+ bool done = false;
C_SafeCond *c;
- C_Sync()
- : lock("C_Sync::lock"), done(false) {
- c = new C_SafeCond(&lock, &cond, &done);
+ C_Sync() {
+ c = new C_SafeCond(lock, cond, &done);
}
~C_Sync() {
- lock.Lock();
+ std::unique_lock l{lock};
//cout << "wait" << std::endl;
- while (!done)
- cond.Wait(lock);
+ cond.wait(l, [this] { return done; });
//cout << "waited" << std::endl;
- lock.Unlock();
}
};
bl.append("small");
int orig_len = fj.prepare_entry(tls, &bl);
fj.reserve_throttle_and_backoff(bl.length());
- fj.submit_entry(1, bl, orig_len, new C_SafeCond(&wait_lock, &cond, &done));
+ fj.submit_entry(1, bl, orig_len, new C_SafeCond(wait_lock, cond, &done));
wait();
fj.close();
vector<ObjectStore::Transaction> tls;
int orig_len = fj.prepare_entry(tls, &bl);
fj.reserve_throttle_and_backoff(bl.length());
- fj.submit_entry(1, bl, orig_len, new C_SafeCond(&wait_lock, &cond, &done));
+ fj.submit_entry(1, bl, orig_len, new C_SafeCond(wait_lock, cond, &done));
wait();
fj.close();
}
ASSERT_EQ(0, fj.create());
ASSERT_EQ(0, fj.make_writeable());
- C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&wait_lock, &cond, &done));
+ C_GatherBuilder gb(g_ceph_context, new C_SafeCond(wait_lock, cond, &done));
vector<ObjectStore::Transaction> tls;
bufferlist bl;
ASSERT_EQ(0, fj.create());
ASSERT_EQ(0, fj.make_writeable());
- C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&wait_lock, &cond, &done));
+ C_GatherBuilder gb(g_ceph_context, new C_SafeCond(wait_lock, cond, &done));
bufferlist first;
first.append("small");
ASSERT_EQ(0, fj.create());
ASSERT_EQ(0, fj.make_writeable());
- C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&wait_lock, &cond, &done));
+ C_GatherBuilder gb(g_ceph_context, new C_SafeCond(wait_lock, cond, &done));
bufferlist bl;
bl.append("small");
uint64_t seq = 0;
ASSERT_EQ(true, fj.read_entry(inbl, seq));
ASSERT_EQ(seq, 2ull);
- inbl.copy(0, inbl.length(), v);
+ inbl.cbegin().copy(inbl.length(), v);
ASSERT_EQ("small", v);
inbl.clear();
v.clear();
ASSERT_EQ(true, fj.read_entry(inbl, seq));
ASSERT_EQ(seq, 3ull);
- inbl.copy(0, inbl.length(), v);
+ inbl.cbegin().copy(inbl.length(), v);
ASSERT_EQ("small", v);
inbl.clear();
v.clear();
ASSERT_EQ(0, fj.create());
ASSERT_EQ(0, fj.make_writeable());
- C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&wait_lock, &cond, &done));
+ C_GatherBuilder gb(g_ceph_context, new C_SafeCond(wait_lock, cond, &done));
const char *needle = "i am a needle";
const char *newneedle = "in a haystack";
uint64_t seq = 0;
ASSERT_EQ(true, fj.read_entry(inbl, seq));
ASSERT_EQ(seq, 2ull);
- inbl.copy(0, inbl.length(), v);
+ inbl.cbegin().copy(inbl.length(), v);
ASSERT_EQ(needle, v);
inbl.clear();
v.clear();
ASSERT_EQ(0, fj.create());
ASSERT_EQ(0, fj.make_writeable());
- C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&wait_lock, &cond, &done));
+ C_GatherBuilder gb(g_ceph_context, new C_SafeCond(wait_lock, cond, &done));
const char *needle = "i am a needle";
for (unsigned i = 1; i <= 4; ++i) {
bl.append("needle");
int orig_len = fj.prepare_entry(tls, &bl);
fj.reserve_throttle_and_backoff(bl.length());
- fj.submit_entry(5, bl, orig_len, new C_SafeCond(&wait_lock, &cond, &done));
+ fj.submit_entry(5, bl, orig_len, new C_SafeCond(wait_lock, cond, &done));
wait();
fj.close();
ASSERT_EQ(0, fj.create());
ASSERT_EQ(0, fj.make_writeable());
- C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&wait_lock, &cond, &done));
+ C_GatherBuilder gb(g_ceph_context, new C_SafeCond(wait_lock, cond, &done));
const char *needle = "i am a needle";
for (unsigned i = 1; i <= 4; ++i) {
bl.append("needle");
int orig_len = fj.prepare_entry(tls, &bl);
fj.reserve_throttle_and_backoff(bl.length());
- fj.submit_entry(5, bl, orig_len, new C_SafeCond(&wait_lock, &cond, &done));
+ fj.submit_entry(5, bl, orig_len, new C_SafeCond(wait_lock, cond, &done));
wait();
fj.close();
ASSERT_EQ(0, fj.create());
ASSERT_EQ(0, fj.make_writeable());
- C_GatherBuilder gb(g_ceph_context, new C_SafeCond(&wait_lock, &cond, &done));
+ C_GatherBuilder gb(g_ceph_context, new C_SafeCond(wait_lock, cond, &done));
const char *needle = "i am a needle";
for (unsigned i = 1; i <= 4; ++i) {
bl.append("needle");
int orig_len = fj.prepare_entry(tls, &bl);
fj.reserve_throttle_and_backoff(bl.length());
- fj.submit_entry(5, bl, orig_len, new C_SafeCond(&wait_lock, &cond, &done));
+ fj.submit_entry(5, bl, orig_len, new C_SafeCond(wait_lock, cond, &done));
wait();
fj.close();