| Advanced Gtk+ Sequencer Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
#include <ags/thread/ags_thread_pool.h> struct AgsThreadPool; struct AgsThreadPoolClass; enum AgsThreadPoolFlags; AgsThreadPool * ags_thread_pool_new (AgsThread *parent); AgsThread * ags_thread_pool_pull (AgsThreadPool *thread_pool);void ags_thread_pool_start (AgsThreadPool *thread_pool);
The AgsThreadPool acts as preinstantiated threads store. This can achieve enormeous performance.
struct AgsThreadPool {
GObject object;
volatile guint flags;
volatile guint max_unused_threads;
volatile guint max_threads;
pthread_t thread;
pthread_mutex_t creation_mutex;
pthread_cond_t creation_cond;
volatile guint n_threads;
volatile guint newly_pulled;
volatile guint queued;
AgsThread *parent;
volatile GList *returnable_thread;
volatile GList *running_thread;
pthread_mutex_t pull_mutex;
pthread_mutex_t return_mutex;
pthread_cond_t return_cond;
};
struct AgsThreadPoolClass {
GObjectClass object;
void (*start)(AgsThreadPool *thread_pool);
};
typedef enum {
AGS_THREAD_POOL_RUNNING = 1,
AGS_THREAD_POOL_READY = 1 << 1,
} AgsThreadPoolFlags;
AgsThreadPool * ags_thread_pool_new (AgsThread *parent);
Create a new AgsThreadPool.
|
the parent AgsThread of returnable threads |
Returns : |
the new AgsThreadPool |
Since 0.4
AgsThread * ags_thread_pool_pull (AgsThreadPool *thread_pool);
Pull a previously instantiated AgsReturnableThread. Note this function may block until a new thread is available.
|
the AgsThreadPool |
Returns : |
a new AgsThread |
Since 0.4
void ags_thread_pool_start (AgsThreadPool *thread_pool);
Start the thread pool.
|
the AgsThreadPool |
Since 0.4