diff --git a/design.txt b/design.txt index 5597e520..69b59eab 100644 --- a/design.txt +++ b/design.txt @@ -24,6 +24,7 @@ Files: file.h filter.h group.h + idle.h index.h library.h playlist.h @@ -35,6 +36,7 @@ Files: database.cpp file.cpp group.cpp + idle.cpp index.cpp library.cpp playlist.cpp @@ -119,6 +121,47 @@ Audio: (lib/audio.cpp) +Idle queue: (lib/idle.cpp) + The idle queue is used to schedule tasks to run at a later time. Idle + tasks must inherit from the IdleBase class so that multiple templated + types can be placed on the same idle queue. + +- IdleBase: + class IdleBase { + IdleBase(); + ~IdleBase(); + virtual void run() = 0; + }; + +- IdleTask: + template + class IdleTask : IdleBase { + private: + void (*func)(T *); + T *data; + + public: + IdleTask(void (*)(T *), T *); + void run(); + }; + +- Queue: + deque(IdleTask *> idle_queue; + float queued = 0.0 + float serviced = 0.0 + +- API: + template + void idle :: schedule(void (*)(T *), T *); + Schedule a function to run later. + queued++ + bool idle :: run_task() + Run the next task on the queue. Return true if a task was + found, and false otherwise. + scheduled++, reset to zero if idle queue is empty. + + + On-disk files: (lib/file.cpp) I use the disk to store data between sessions, this could include library state and user preferences. In theory, file formats do not @@ -243,7 +286,8 @@ Database: (lib/database.cpp) an empty string if you do not want this database to be saved. Database.load(); Reads data from file. Call after static initialization of - Ocarina to ensure idle tasks are configured. + Ocarina to ensure idle tasks are configured so loading can + happen at a later time. Database.save(); Saves data to file. Database.insert(T &);