Implement file::flush()

This commit is contained in:
Avi Kivity
2014-08-24 11:04:59 +03:00
parent 2bec091b9e
commit 754a245d59
2 changed files with 13 additions and 1 deletions

View File

@@ -189,6 +189,15 @@ reactor::open_file_dma(sstring name) {
});
}
future<>
reactor::flush(file& f) {
return _thread_pool.submit<syscall_result<int>>([&f] {
return wrap_syscall<int>(::fsync(f._fd));
}).then([] (syscall_result<int> sr) {
assert(sr.result != -1);
return make_ready_future<>();
});
}
void reactor::run() {
std::vector<std::unique_ptr<task>> current_tasks;

View File

@@ -423,6 +423,7 @@ public:
future<size_t> write_all(pollable_fd_state& fd, const void* buffer, size_t size);
future<file> open_file_dma(sstring name);
future<> flush(file& f);
void run();
@@ -603,7 +604,9 @@ public:
return the_reactor.write_dma(*this, pos, std::move(iov));
}
future<> flush();
future<> flush() {
return the_reactor.flush(*this);
}
friend class reactor;
};