X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=frame_on_disk.h;h=184385792528130df7e3ba16637385c0c14a35db;hb=3795723be95f2fe82f3c8b8b45b1a905b2c811fd;hp=a0f46ad171ab6bf0e4d91a846a99727fae0c6691;hpb=bdef311c334b674ba39a931805fb7d32ce8698da;p=nageru diff --git a/frame_on_disk.h b/frame_on_disk.h index a0f46ad..1843857 100644 --- a/frame_on_disk.h +++ b/frame_on_disk.h @@ -19,6 +19,19 @@ struct FrameOnDisk { extern std::vector frames[MAX_STREAMS]; // Under frame_mu. extern std::vector frame_filenames; // Under frame_mu. -std::string read_frame(FrameOnDisk frame); +// A helper class to read frames from disk. It caches the file descriptor +// so that the kernel has a better chance of doing readahead when it sees +// the sequential reads. (For this reason, each display has a private +// FrameReader. Thus, we can easily keep multiple open file descriptors around +// for a single .frames file.) +class FrameReader { +public: + ~FrameReader(); + std::string read_frame(FrameOnDisk frame); + +private: + int fd = -1; + int last_filename_idx = -1; +}; #endif // !defined(_FRAME_ON_DISK_H)