#include <set>
#include <iostream>
+#include <tr1/memory>
#define mydout(cct, v) lgeneric_subdout(cct, context, v)
void finish(int 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;
/*
* finish and destroy a list of Contexts
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,
void register_on_applied_sync(Context *c) {
on_applied_sync.push_back(c);
}
+ void register_on_complete(Context *c) {
+ RunOnDeleteRef _complete(new RunOnDelete(c));
+ register_on_applied(new ContainerContext<RunOnDeleteRef>(_complete));
+ register_on_commit(new ContainerContext<RunOnDeleteRef>(_complete));
+ }
static void collect_contexts(
list<Transaction *> &t,