}
void JournalRecorder::flush(Context *on_safe) {
- Mutex::Locker locker(m_lock);
-
- C_Flush *ctx = new C_Flush(on_safe, m_object_ptrs.size());
- for (ObjectRecorderPtrs::iterator it = m_object_ptrs.begin();
- it != m_object_ptrs.end(); ++it) {
- it->second->flush(ctx);
+ C_Flush *ctx;
+ {
+ Mutex::Locker locker(m_lock);
+
+ ctx = new C_Flush(on_safe, m_object_ptrs.size());
+ for (ObjectRecorderPtrs::iterator it = m_object_ptrs.begin();
+ it != m_object_ptrs.end(); ++it) {
+ it->second->flush(ctx);
+ }
}
+
+ ctx->unblock();
}
ObjectRecorderPtr JournalRecorder::get_object(uint8_t splay_offset) {
int ret_val;
C_Flush(Context *_on_finish, size_t _pending_flushes)
- : on_finish(_on_finish), pending_flushes(_pending_flushes), ret_val(0) {
+ : on_finish(_on_finish), pending_flushes(_pending_flushes + 1),
+ ret_val(0) {
}
+ void unblock() {
+ complete(0);
+ }
virtual void complete(int r) {
if (r < 0 && ret_val == 0) {
ret_val = r;