cp_pooled_thread_scheduler *
cp_pooled_thread_scheduler_create(cp_thread_pool *pool);
void cp_pooled_thread_scheduler_destroy(
cp_pooled_thread_scheduler *scheduler);
void cp_pooled_thread_scheduler_register_client(
cp_pooled_thread_scheduler *scheduler,
cp_pooled_thread_client_interface* client );
o create a thread pool
o instantiate the scheduler with the thread pool
o create cp_pooled_thread_client_interfaces instances describing the
actions to be load balanced
o register the client interface instances with the scheduler.
cp_pooled_thread_scheduler_create creates a scheduler instance for the specified pool. cp_pooled_thread_scheduler_destroy performs cleanup of scheduler instances. cp_pooled_thread_scheduler_register_client registers a client with the scheduler.
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 cp_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 *.
This document was created by
man2html,
using the manual pages. Time: 17:35:34 GMT, December 30, 2005 |