Due to the nature of the structure and task, Gzz is mostly a single-threaded program. However, there are some situations where running some jobs in the background will be useful, e.g. loading images, and we need a reasonable framework for this.
One problem is that there are two kinds of background jobs: real background jobs that do not much interact with the rest of the system, which can be executed in a separate thread, and "pseudo" background jobs (idletasks) which use the structure or OpenGL context or whatever and need to be executed in the main thread.
Because of this, we have the following structure:
The class PriorityQueue provides a simple set from which the object with the highest priority (lowest number) can be drawn. The classes UpdateManager and Background make use of this; the Background class has its own thread, while UpdateManager performs the idle tasks just before waiting for events.