#ifndef STREAM_IO_H #define STREAM_IO_H #include #include #include #include #include class CStreamIO; typedef shared_ptr StreamIO; class CStreamIO: public CRunnable { private: Path path_; Stream stream_; std::ofstream file_; mutable CMtx mutex_; uint8_t *buf; protected: // to be implemented by subclasses virtual void* threadBody(); public: CStreamIO(const char* name, Path p); static StreamIO create(const char* name, Path p); void openFile(const char* file_name); void closeFile(); bool tryWriteFile(const char *data, uint64_t size); // Destructor of subclass should call stop -- cannot // rely on base class to do so because subclass // data is already torn down! virtual ~CStreamIO(); }; #endif