Chapter 3. Multi-/Super-threaded tree

Table of Contents

The main loop interface
Threads in general
Pulling threads of thread pool
Worker-threads to do tic-less parallelism
Asynchronously destroy objects
Poll for file descriptors
Launching tasks
Mutex and condition manager

Advanced Gtk+ Sequencer comes with an AgsThread object. It is organized as a tree structure. The API provides many functions to work with it. These threads do the ::clock event where all threads synchronize.

The AgsTaskThread runs synchronized as well but is going to be waited after syncing to run all tasks. The AgsTask signal ::launch runs asynchronous exclusively. So the task thread implements AgsAsyncQueue interface. Every thread tree shall have at toplevel a thread implementing AgsMainLoop interface.

There is an object call AgsThreadPool serving prelaunched threads. It returns on pull AgsReturnableThread instances. They can be used with a callback ::safe-run.

There is a interface to implement by your application context. Thus the AgsConcurrencyProvider interface is used. It has some common get/set functions to do basic multi-threaded work by well defined objects.

The main loop interface

AgsMainLoop should be implemented by toplevel threads. Within a thread tree this is the topmost element. It has various get and set methods you would expect. ::set_tic and ::get_tic is used for synchronization purpose as well ::set_last_sync and ::get_last_sync. ::get_async_queue should return an instance implementing AgsAsyncQueue eg. AgsTaskThread. ::get_application_context returns the AgsApplicationContext.