};
void BucketIndexAioManager::do_completion(int id) {
- Mutex::Locker l(lock);
+ std::lock_guard l{lock};
map<int, librados::AioCompletion*>::iterator iter = pendings.find(id);
ceph_assert(iter != pendings.end());
pending_objs.erase(miter);
}
- cond.Signal();
+ cond.notify_all();
}
bool BucketIndexAioManager::wait_for_completions(int valid_ret_code,
int *num_completions, int *ret_code, map<int, string> *objs) {
- lock.Lock();
+ std::unique_lock locker{lock};
if (pendings.empty() && completions.empty()) {
- lock.Unlock();
return false;
}
if (completions.empty()) {
// Wait for AIO completion
- cond.Wait(lock);
+ cond.wait(locker);
}
// Clear the completed AIOs
if (num_completions)
(*num_completions) = completions.size();
completions.clear();
- lock.Unlock();
return true;
}
#include "common/RefCountedObj.h"
#include "include/compat.h"
#include "common/ceph_time.h"
-#include "common/Mutex.h"
-#include "common/Cond.h"
+#include "common/ceph_mutex.h"
// Forward declaration
class BucketIndexAioManager;
map<int, librados::AioCompletion*> completions;
map<int, string> pending_objs;
map<int, string> completion_objs;
- int next;
- Mutex lock;
- Cond cond;
+ int next = 0;
+ ceph::mutex lock = ceph::make_mutex("BucketIndexAioManager::lock");
+ ceph::condition_variable cond;
/*
* Callback implementation for AIO request.
*/
/*
* Create a new instance.
*/
- BucketIndexAioManager() : next(0), lock("BucketIndexAioManager::lock") {}
-
+ BucketIndexAioManager() = default;
/*
* Do completion for the given AIO request.
* Do aio read operation.
*/
bool aio_operate(librados::IoCtx& io_ctx, const string& oid, librados::ObjectReadOperation *op) {
- Mutex::Locker l(lock);
+ std::lock_guard l{lock};
BucketIndexAioArg *arg = new BucketIndexAioArg(get_next(), this);
librados::AioCompletion *c = librados::Rados::aio_create_completion((void*)arg, NULL, bucket_index_op_completion_cb);
int r = io_ctx.aio_operate(oid, c, (librados::ObjectReadOperation*)op, NULL);
* Do aio write operation.
*/
bool aio_operate(librados::IoCtx& io_ctx, const string& oid, librados::ObjectWriteOperation *op) {
- Mutex::Locker l(lock);
+ std::lock_guard l{lock};
BucketIndexAioArg *arg = new BucketIndexAioArg(get_next(), this);
librados::AioCompletion *c = librados::Rados::aio_create_completion((void*)arg, NULL, bucket_index_op_completion_cb);
int r = io_ctx.aio_operate(oid, c, (librados::ObjectWriteOperation*)op);