class Core::Portable::FileIOManager
Overview
Manager singleton for asynchronous file operations. More…
#include <corefile.h> class FileIOManager: public Core::Portable::StaticSingleton { public: // typedefs typedef FileStorageContext::Mode StorageMode; // structs struct DataSaveTask; struct ExternalTask; struct LoadTask; struct NotifyEntry; struct PromiseSaveTask; struct SaveTask; // classes class Worker; // methods void setPriority(Threads::ThreadPriority priority); FileIOTaskID addSaveTask( CStringPtr filename, IO::MemoryStream* data, FileIOCompletionHandler* completionHandler = nullptr, StorageMode mode = FileStorageContext::kCopy ); FileIOTaskID addSaveTask( CStringPtr filename, FileDataPromise* promise, FileIOCompletionHandler* completionHandler = nullptr, StorageMode mode = FileStorageContext::kCopy ); FileIOTaskID addLoadTask( CStringPtr filename, FileIOCompletionHandler* completionHandler, StorageMode mode = FileStorageContext::kCopy ); FileIOTaskID addExternalTask( BackgroundTask* task, CStringPtr filename = nullptr, FileIOCompletionHandler* completionHandler = nullptr, bool isSaveTask = true ); void cancelTask(FileIOTaskID id); void idle(); void terminate(); bool hasTasks() const; int countTasks() const; };
Inherited Members
public: // methods static T& instance(); DeletableList& instance();
Detailed Documentation
Manager singleton for asynchronous file operations.
Make sure to call idle and terminate in your application!
Methods
void setPriority(Threads::ThreadPriority priority)
Set file I/O thread priority (default is low).
FileIOTaskID addSaveTask( CStringPtr filename, IO::MemoryStream* data, FileIOCompletionHandler* completionHandler = nullptr, StorageMode mode = FileStorageContext::kCopy )
Save data from memory stream to disk asynchronously.
FileIOTaskID addSaveTask( CStringPtr filename, FileDataPromise* promise, FileIOCompletionHandler* completionHandler = nullptr, StorageMode mode = FileStorageContext::kCopy )
Save data provided by a promise object to disk asynchronously.
FileIOTaskID addLoadTask( CStringPtr filename, FileIOCompletionHandler* completionHandler, StorageMode mode = FileStorageContext::kCopy )
Load data from disk into memory stream asynchronously.
FileIOTaskID addExternalTask( BackgroundTask* task, CStringPtr filename = nullptr, FileIOCompletionHandler* completionHandler = nullptr, bool isSaveTask = true )
Add external background task.
Use if you need special behavior not implemented by this class.
void cancelTask(FileIOTaskID id)
Cancel queued background task.
void idle()
Idle needs to be called periodically by the application.
void terminate()
Terminate needs to be called once on application exit.
bool hasTasks() const
Check if there are tasks in the queue.
int countTasks() const
Count the tasks in the queue.