|
design_pattern_for_c
V 1.00
|
This is API as ThreadPool design petten by using libevent. More...
#include "event_threadpool_data.h"

Go to the source code of this file.
Functions | |
API for EventTPoolManager instance | |
| EventTPoolManager | event_tpool_manager_new (int thread_num, int is_threadsafe, const char *plugin_path) |
| new EventTPoolManager More... | |
| void | event_tpool_manager_free (EventTPoolManager this) |
| destructor of EventTPoolManager More... | |
| size_t | event_tpool_manager_get_threadnum (EventTPoolManager this) |
| get size of thread More... | |
API for EventThreadPool | |
| event_tpool_add_result_t | event_tpool_add (EventTPoolManager this, EventSubscriber subscriber, void *arg) |
| add EventSubscriber to threadpool More... | |
| event_tpool_add_result_t | event_tpool_add_thread (EventTPoolManager this, int threadid, EventSubscriber subscriber, void *arg) |
| add EventSubscriber to threadpool, if you want to choose thead, please use it. More... | |
| event_tpool_add_result_t | event_tpool_update (EventTPoolManager this, EventTPoolThreadInfo event_handle, EventSubscriber subscriber, void *arg) |
| update EventSubscriber to threadpool. More... | |
| void | event_tpool_del (EventTPoolManager this, int fd) |
| delete EventSubscriber to threadapool. More... | |
| void | event_tpool_atfork_child (EventTPoolManager this) |
| Update member at fork, please call this API on child process if you use fork. More... | |
| void | event_tpool_set_stack_size (size_t stack_size) |
| Set thread stack size. More... | |
This is API as ThreadPool design petten by using libevent.
Definition in file event_threadpool.h.
| event_tpool_add_result_t event_tpool_add | ( | EventTPoolManager | this, |
| EventSubscriber | subscriber, | ||
| void * | arg | ||
| ) |
add EventSubscriber to threadpool
| [in] | this | EventTPoolManager instance returned at event_tpool_new. |
| [in] | subscriber | EventSubscriber |
| [in] | arg | argument for event_callback |
| result | thread number (0-thread_num-1) which subscriber added, event_handle is used for update |
| result | <0 error (no resource, or if a same fd's subscriber was already registred) |
Definition at line 343 of file event_tpool_manager.c.


| event_tpool_add_result_t event_tpool_add_thread | ( | EventTPoolManager | this, |
| int | threadid, | ||
| EventSubscriber | subscriber, | ||
| void * | arg | ||
| ) |
add EventSubscriber to threadpool, if you want to choose thead, please use it.
| [in] | this | EventTPoolManager instance returned at event_tpool_new. |
| [in] | threadid | thread id (0-thread_num-1) |
| [in] | subscriber | EventSubscriber |
| [in] | arg | argument for event_callback |
| result | thread number (0-thread_num-1) which subscriber added, event_handle is used for update |
| result | <0 error (no resource, or if a same fd's subscriber was already registred) |
Definition at line 373 of file event_tpool_manager.c.

| void event_tpool_atfork_child | ( | EventTPoolManager | this | ) |
Update member at fork, please call this API on child process if you use fork.
| [in] | this | EventTPoolManager instance returned at event_tpool_new. |
Definition at line 453 of file event_tpool_manager.c.

| void event_tpool_del | ( | EventTPoolManager | this, |
| int | fd | ||
| ) |
delete EventSubscriber to threadapool.
| [in] | this | EventTPoolManager instance returned at event_tpool_new. |
| [in] | fd | removed fd (related to subscriber) |
Definition at line 430 of file event_tpool_manager.c.


| void event_tpool_manager_free | ( | EventTPoolManager | this | ) |
destructor of EventTPoolManager
| [in] | this | EventTPoolManager instance returned at event_tpool_new. |
Definition at line 319 of file event_tpool_manager.c.

| size_t event_tpool_manager_get_threadnum | ( | EventTPoolManager | this | ) |
get size of thread
| [in] | this | EventTPoolManager instance returned at event_tpool_new. |
| size | of thread |
| -1 | error |
Definition at line 331 of file event_tpool_manager.c.
| EventTPoolManager event_tpool_manager_new | ( | int | thread_num, |
| int | is_threadsafe, | ||
| const char * | plugin_path | ||
| ) |
new EventTPoolManager
| [in] | thread_num | size of thread. If this is negative value, this library set thread CPU number * 2 |
| [in] | is_threadsafe | if you use this instance in multi thread, please set 1. |
| [in] | plugin_path | if you want to choose plugin. Default : choose higher priority plugin from prefix |
| !=NULL | this class handle |
| NULL | error |
Definition at line 278 of file event_tpool_manager.c.


| void event_tpool_set_stack_size | ( | size_t | stack_size | ) |
Set thread stack size.
Default is 256 KByte.
| [in] | stack_size | stack size. |
Definition at line 462 of file event_tpool_manager.c.

| event_tpool_add_result_t event_tpool_update | ( | EventTPoolManager | this, |
| EventTPoolThreadInfo | event_handle, | ||
| EventSubscriber | subscriber, | ||
| void * | arg | ||
| ) |
update EventSubscriber to threadpool.
if you want to choose thead, please use it.
| [in] | this | EventTPoolManager instance returned at event_tpool_new. |
| [in] | event_handle | handler of event returned at event_tpool_add/event_tpool_add_thread |
| [in] | subscriber | EventSubscriber |
| [in] | arg | argument for event_callback |
| result | thread number (0-thread_num-1) which subscriber added |
| result | <0 error (no resource, or if a same fd's subscriber was already registred) |
Definition at line 403 of file event_tpool_manager.c.
