*/
int rados_aio_is_safe(rados_completion_t c);
+/**
+ * Block until an operation completes and callback completes
+ *
+ * This means it is in memory on all replicas and can be read.
+ *
+ * @note BUG: this should be void
+ *
+ * @param c operation to wait for
+ * @returns 0
+ */
+int rados_aio_wait_for_complete_and_cb(rados_completion_t c);
+
+/**
+ * Block until an operation is safe and callback has completed
+ *
+ * This means it is on stable storage on all replicas.
+ *
+ * @note BUG: this should be void
+ *
+ * @param c operation to wait for
+ * @returns 0
+ */
+int rados_aio_wait_for_safe_and_cb(rados_completion_t c);
+
+/**
+ * Has an asynchronous operation and callback completed
+ *
+ * @param c async operation to inspect
+ * @returns whether c is complete
+ */
+int rados_aio_is_complete_and_cb(rados_completion_t c);
+
+/**
+ * Is an asynchronous operation safe and has the callback completed
+ *
+ * @param c async operation to inspect
+ * @returns whether c is safe
+ */
+int rados_aio_is_safe_and_cb(rados_completion_t c);
+
/**
* Get the return value of an asychronous operation
*
int set_safe_callback(void *cb_arg, callback_t cb);
int wait_for_complete();
int wait_for_safe();
+ int wait_for_complete_and_cb();
+ int wait_for_safe_and_cb();
bool is_complete();
bool is_safe();
+ bool is_complete_and_cb();
+ bool is_safe_and_cb();
int get_return_value();
int get_version();
void release();
lock.Unlock();
return r;
}
+ int wait_for_complete_and_cb() {
+ lock.Lock();
+ while (!ack || callback_complete)
+ cond.Wait(lock);
+ lock.Unlock();
+ return 0;
+ }
+ int wait_for_safe_and_cb() {
+ lock.Lock();
+ while (!safe || callback_safe)
+ cond.Wait(lock);
+ lock.Unlock();
+ return 0;
+ }
+ int is_complete_and_cb() {
+ lock.Lock();
+ int r = ack && !callback_complete;
+ lock.Unlock();
+ return r;
+ }
+ int is_safe_and_cb() {
+ lock.Lock();
+ int r = safe && !callback_safe;
+ lock.Unlock();
+ return r;
+ }
int get_return_value() {
lock.Lock();
int r = rval;
rados_callback_t cb = c->callback_complete;
void *cb_arg = c->callback_arg;
cb(c, cb_arg);
- c->put();
+
+ c->lock.Lock();
+ c->callback_complete = NULL;
+ c->cond.Signal();
+ c->put_unlock();
}
};
rados_callback_t cb = c->callback_safe;
void *cb_arg = c->callback_arg;
cb(c, cb_arg);
- c->put();
+
+ c->lock.Lock();
+ c->callback_safe = NULL;
+ c->cond.Signal();
+ c->put_unlock();
}
};
return c->is_safe();
}
+int librados::AioCompletion::AioCompletion::wait_for_complete_and_cb()
+{
+ AioCompletionImpl *c = (AioCompletionImpl *)pc;
+ return c->wait_for_complete_and_cb();
+}
+
+int librados::AioCompletion::AioCompletion::wait_for_safe_and_cb()
+{
+ AioCompletionImpl *c = (AioCompletionImpl *)pc;
+ return c->wait_for_safe_and_cb();
+}
+
+bool librados::AioCompletion::AioCompletion::is_complete_and_cb()
+{
+ AioCompletionImpl *c = (AioCompletionImpl *)pc;
+ return c->is_complete_and_cb();
+}
+
+bool librados::AioCompletion::AioCompletion::is_safe_and_cb()
+{
+ AioCompletionImpl *c = (AioCompletionImpl *)pc;
+ return c->is_safe_and_cb();
+}
+
int librados::AioCompletion::AioCompletion::get_return_value()
{
AioCompletionImpl *c = (AioCompletionImpl *)pc;
return ((librados::AioCompletionImpl*)c)->is_safe();
}
+extern "C" int rados_aio_wait_for_complete_and_cb(rados_completion_t c)
+{
+ return ((librados::AioCompletionImpl*)c)->wait_for_complete_and_cb();
+}
+
+extern "C" int rados_aio_wait_for_safe_and_cb(rados_completion_t c)
+{
+ return ((librados::AioCompletionImpl*)c)->wait_for_safe_and_cb();
+}
+
+extern "C" int rados_aio_is_complete_and_cb(rados_completion_t c)
+{
+ return ((librados::AioCompletionImpl*)c)->is_complete_and_cb();
+}
+
+extern "C" int rados_aio_is_safe_and_cb(rados_completion_t c)
+{
+ return ((librados::AioCompletionImpl*)c)->is_safe_and_cb();
+}
+
extern "C" int rados_aio_get_return_value(rados_completion_t c)
{
return ((librados::AioCompletionImpl*)c)->get_return_value();
o.append(bl2);
}
ASSERT_EQ(0, ioctx.aio_operate("foo", my_completion, &o));
- ASSERT_EQ(0, my_completion->wait_for_complete());
+ ASSERT_EQ(0, my_completion->wait_for_complete_and_cb());
ASSERT_EQ(my_aio_complete, true);
uint64_t size;