Design: Put in idle queue information

This is needed for scheduling files to load later.

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2013-07-05 10:39:55 -04:00 committed by Anna Schumaker
parent f75ba5a2b8
commit d8c8ea1bbf
1 changed files with 45 additions and 1 deletions

View File

@ -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 T>
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 <class T>
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 &);