Add close handling, move clock example to split threads

This commit is contained in:
flamingcow
2019-05-11 21:53:12 -07:00
parent c5f5d9f0cf
commit 1f84aa25b6
6 changed files with 72 additions and 13 deletions

View File

@@ -3,7 +3,17 @@
namespace firesse {
Stream::Stream(firecgi::Request* request)
: request_(request) {}
: request_(request) {
request->OnClose([this]() {
if (on_close_) {
on_close_();
}
});
}
void Stream::OnClose(const std::function<void()>& callback) {
on_close_ = callback;
}
bool Stream::WriteEvent(const std::string& data, uint64_t id, const std::string& type) {
return request_->InTransaction<bool>([=]() {