AgsThreadPool

AgsThreadPool — thread pool

Synopsis

#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);

Description

The AgsThreadPool acts as preinstantiated threads store. This can achieve enormeous performance.

Details

struct AgsThreadPool

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

struct AgsThreadPoolClass {
  GObjectClass object;

  void (*start)(AgsThreadPool *thread_pool);
};

enum AgsThreadPoolFlags

typedef enum {
  AGS_THREAD_POOL_RUNNING  = 1,
  AGS_THREAD_POOL_READY    = 1 << 1,
} AgsThreadPoolFlags;

ags_thread_pool_new ()

AgsThreadPool *     ags_thread_pool_new                 (AgsThread *parent);

Create a new AgsThreadPool.

parent :

the parent AgsThread of returnable threads

Returns :

the new AgsThreadPool

Since 0.4


ags_thread_pool_pull ()

AgsThread *         ags_thread_pool_pull                (AgsThreadPool *thread_pool);

Pull a previously instantiated AgsReturnableThread. Note this function may block until a new thread is available.

thread_pool :

the AgsThreadPool

Returns :

a new AgsThread

Since 0.4


ags_thread_pool_start ()

void                ags_thread_pool_start               (AgsThreadPool *thread_pool);

Start the thread pool.

thread_pool :

the AgsThreadPool

Since 0.4