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:
parent
f75ba5a2b8
commit
d8c8ea1bbf
46
design.txt
46
design.txt
|
@ -24,6 +24,7 @@ Files:
|
||||||
file.h
|
file.h
|
||||||
filter.h
|
filter.h
|
||||||
group.h
|
group.h
|
||||||
|
idle.h
|
||||||
index.h
|
index.h
|
||||||
library.h
|
library.h
|
||||||
playlist.h
|
playlist.h
|
||||||
|
@ -35,6 +36,7 @@ Files:
|
||||||
database.cpp
|
database.cpp
|
||||||
file.cpp
|
file.cpp
|
||||||
group.cpp
|
group.cpp
|
||||||
|
idle.cpp
|
||||||
index.cpp
|
index.cpp
|
||||||
library.cpp
|
library.cpp
|
||||||
playlist.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)
|
On-disk files: (lib/file.cpp)
|
||||||
I use the disk to store data between sessions, this could include
|
I use the disk to store data between sessions, this could include
|
||||||
library state and user preferences. In theory, file formats do not
|
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.
|
an empty string if you do not want this database to be saved.
|
||||||
Database.load();
|
Database.load();
|
||||||
Reads data from file. Call after static initialization of
|
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();
|
Database.save();
|
||||||
Saves data to file.
|
Saves data to file.
|
||||||
Database.insert(T &);
|
Database.insert(T &);
|
||||||
|
|
Loading…
Reference in New Issue