Separate Index class to track streams via intrusive list

This commit is contained in:
flamingcow
2019-05-12 08:45:56 -07:00
parent 79709c5b25
commit d29157c1ac
7 changed files with 84 additions and 29 deletions

View File

@@ -6,30 +6,31 @@
namespace firesse {
class Index;
class Stream {
public:
Stream(firecgi::Request* request);
Stream(firecgi::Request* request, Index* index);
~Stream();
void OnClose(const std::function<void()>& callback);
bool WriteEvent(const std::string& data, uint64_t id=0, const std::string& type="");
bool End();
std::chrono::steady_clock::time_point LastMessageTime();
void Close();
private:
firecgi::Request* request_;
Index* index_;
std::function<void()> on_close_;
std::mutex mu_;
std::chrono::steady_clock::time_point last_message_time_;
};
Stream* fresher_;
Stream* staler_;
class IsFresherStream {
public:
bool operator() (Stream* a, Stream* b) const;
friend class Index;
};
} // namespace firesse