Data Fields

cp_pooled_thread_scheduler Struct Reference
[Cp_thread]

Definitions for thread management framework follow. More...

#include <thread.h>

Data Fields

cp_thread_poolpool
 pool to operate on
cp_vector * client_list
 list of clients
int bypass
 when bypass flag set 'negociate' function becomes nop

Detailed Description

Definitions for thread management framework follow.

The framework is based on the cp_thread_pool and cp_pooled_thread types.
The pooled thread scheduler interface is meant for use by clients who require a variable number of threads. Each such component should create an instance of cp_pooled_thread_client_interface and use the api functions to get threads from the underlying cp_thread_pool. Here is some example code.

 cp_pooled_thread_scheduler *main_scheduler;

 ...

 component_a_start(component_a *a, ...)
 {
     a->scheduler_interface = 
         cp_pooled_thread_client_interface_create(main_scheduler, a, 2, 10, 
             component_a_report_load, component_a_stop_thread, 
             component_a_thread_run, a);

     ...

     for (i = 0; i < a->scheduler_interface->min; i++)
         cp_pooled_thread_client_get(a->scheduler_interface);
 }

 component_b_start(component_b *b, ...)
 {
     b->scheduler_interface = 
         cp_pooled_thread_client_interface_create(main_scheduler, b, 2, 10, 
             component_a_report_load, component_a_stop_thread, 
             component_a_thread_run, b);

     ...

     for (i = 0; i < b->scheduler_interface->min; i++)
         cp_pooled_thread_client_get(b->scheduler_interface);
 }

 


In this example, the threads for component_a and component_b will be managed jointly, since their cp_pooled_thread_client_interface *'s have the same cp_pooled_thread_scheduler *.

See cp_pooled_thread_client_negociate for details.


The documentation for this struct was generated from the following file: