*
*/
#include <sstream>
+#include <tr1/memory>
#include "ObjectStore.h"
#include "common/Formatter.h"
return r;
}
+template <class T>
+struct Wrapper : public Context {
+ Context *to_run;
+ T val;
+ Wrapper(Context *to_run, T val) : to_run(to_run), val(val) {}
+ void finish(int r) {
+ if (to_run)
+ to_run->complete(r);
+ }
+};
+struct RunOnDelete {
+ Context *to_run;
+ RunOnDelete(Context *to_run) : to_run(to_run) {}
+ ~RunOnDelete() {
+ if (to_run)
+ to_run->complete(0);
+ }
+};
+typedef std::tr1::shared_ptr<RunOnDelete> RunOnDeleteRef;
+int ObjectStore::queue_transactions(
+ Sequencer *osr,
+ list<Transaction*>& tls,
+ Context *onreadable,
+ Context *oncommit,
+ Context *onreadable_sync,
+ Context *oncomplete,
+ TrackedOpRef op = TrackedOpRef())
+{
+ RunOnDeleteRef _complete(new RunOnDelete(oncomplete));
+ Context *_onreadable = new Wrapper<RunOnDeleteRef>(
+ onreadable, _complete);
+ Context *_oncommit = new Wrapper<RunOnDeleteRef>(
+ oncommit, _complete);
+ return queue_transactions(osr, tls, _onreadable, _oncommit,
+ onreadable_sync, op);
+}
+
void ObjectStore::Transaction::dump(ceph::Formatter *f)
{
f->open_array_section("ops");
Context *onreadable_sync=0,
TrackedOpRef op = TrackedOpRef()) = 0;
+ int queue_transactions(
+ Sequencer *osr,
+ list<Transaction*>& tls,
+ Context *onreadable,
+ Context *oncommit,
+ Context *onreadable_sync,
+ Context *oncomplete,
+ TrackedOpRef op);
+
+ int queue_transaction(
+ Sequencer *osr,
+ Transaction* t,
+ Context *onreadable,
+ Context *oncommit,
+ Context *onreadable_sync,
+ Context *oncomplete,
+ TrackedOpRef op) {
+ list<Transaction*> tls;
+ tls.push_back(t);
+ return queue_transactions(
+ osr, tls, onreadable, oncommit, onreadable_sync, oncomplete, op);
+ }
+
public:
ObjectStore() : logger(NULL) {}
virtual ~ObjectStore() {}