Logo Search packages:      
Sourcecode: ardour version File versions

Glib::ThreadPool::ThreadPool ( int  max_threads = -1,
bool  exclusive = false 
) [explicit]

Constructs a new thread pool. Whenever you call ThreadPool::push(), either a new thread is created or an unused one is reused. At most max_threads threads are running concurrently for this thread pool. max_threads = -1 allows unlimited threads to be created for this thread pool.

The parameter exclusive determines, whether the thread pool owns all threads exclusive or whether the threads are shared globally. If exclusive is true, max_threads threads are started immediately and they will run exclusively for this thread pool until it is destroyed by ~ThreadPool(). If exclusive is false, threads are created when needed and shared between all non-exclusive thread pools. This implies that max_threads may not be -1 for exclusive thread pools.

Parameters:
max_threads The maximal number of threads to execute concurrently in the new thread pool, -1 means no limit.
exclusive Should this thread pool be exclusive?
Exceptions:
Glib::ThreadError An error can only occur when exclusive is set to true and not all max_threads threads could be created.

Definition at line 129 of file threadpool.cc.

:
  gobject_   (0),
  slot_list_ (new SlotList())
{
  GError* error = 0;

  gobject_ = g_thread_pool_new(
      &call_thread_entry_slot, slot_list_, max_threads, exclusive, &error);

  if(error)
  {
    delete slot_list_;
    slot_list_ = 0;
    Glib::Error::throw_exception(error);
  }
}


Generated by  Doxygen 1.6.0   Back to index