| 
    design_pattern_for_c
    V 1.00
    
   | 
 
This is API implement for EventTPoolManager class. More...
#include <elf.h>#include <stdio.h>#include <sched.h>#include "config.h"#include "event_threadpool.h"#include "event_thread.h"#include "dp_util.h"
Go to the source code of this file.
Data Structures | |
| struct | event_tpool_thread_info_t | 
| union | event_tpool_thread_info_t::data_fds_u | 
| struct | event_tpool_manager_t | 
| EventTPoolManager class instance definition.  More... | |
Macros | |
| #define | _GNU_SOURCE | 
| #define | EV_TPOLL_FD_START (3) | 
| #define | EV_TPOLL_FDSU64PLACE(fd) (((fd)-EV_TPOLL_FD_START)/EV_TPOLL_U64_BITSIZE) | 
| #define | EV_TPOLL_FDINDEX(fd, place) ((fd) - ((place)*EV_TPOLL_USABLE_BITSIZE) - EV_TPOLL_FD_START) | 
| #define | EV_TPOLL_FDINDEX_U8(fd, place, place_u8) (EV_TPOLL_FDINDEX(fd,place) - ((place_u8) * EV_TPOLL_U8_BITSIZE)) | 
| #define | EV_TPOLL_FD(place, place_u8, index) (index + ((place)*EV_TPOLL_USABLE_BITSIZE) + ((place_u8) * EV_TPOLL_U8_BITSIZE) + EV_TPOLL_FD_START) | 
Functions | |
| static int | event_tpoll_get_far_right_bit_index (uint8_t data) | 
| static void | event_tpool_free_fddata (EventTPoolThreadInfo this, int place) | 
| static void | event_tpool_thread_delete_thread (EventTPoolThreadInfo this, int fd) | 
| delete thread  More... | |
thread information list API definition.  | |
| static void | event_tpool_thread_info_start_thread (EventTPoolThreadInfo instance) | 
| start thread  More... | |
| static void | event_tpool_thread_info_stop_thread (EventTPoolThreadInfo this) | 
| stop thread  More... | |
| static int | event_tpool_thread_has_fd (EventTPoolThreadInfo this, int fd) | 
| search current setting  More... | |
EventTPoolThreadInfo list API and EventTPoolFDData list API definition.  | |
| static EventTPoolThreadInfo | event_tpool_thread_info_new (size_t thread_size, const char *plugin_path) | 
| new thread info  More... | |
| static void | event_tpool_thread_info_free (EventTPoolThreadInfo this, size_t thread_size) | 
| free thread info  More... | |
| static void | event_tpool_free_fddata_list (EventTPoolThreadInfo this) | 
| free fddata  More... | |
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... | |
| 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... | |
thread information list definition. | |
| #define | EV_TPOLL_U64_BITSIZE (64) | 
| thread instance and fd list  More... | |
| #define | EV_TPOLL_U8_BITSIZE (8) | 
| #define | EV_TPOLL_USABLE_BITSIZE (64) | 
| typedef struct event_tpool_thread_info_t | event_tpool_thread_info_t | 
| typedef union data_fds_u | data_fds_u | 
| static void | event_tpool_thread_set_fds (EventTPoolThreadInfo this, int fd) | 
| static void | event_tpool_thread_unset_fds (EventTPoolThreadInfo this, int fd) | 
| static int | event_tpool_thread_is_set_fds (EventTPoolThreadInfo this, int fd) | 
| static void | event_tpool_thread_insert_fddata (EventTPoolThreadInfo this, int fd) | 
for EventTPoolManager private API definition . | |
| #define | EVT_TPOOL_MNG_LOCK(this) DPUTIL_LOCK(this->lock); | 
| #define | EVT_TPOOL_MNG_UNLOCK DPUTIL_UNLOCK; | 
| static void | event_tpool_manager_free_without_lock (EventTPoolManager this) | 
| static int | event_tpool_manager_get_default_thrednum (void) | 
| static int | event_tpool_manager_search_insert_thread (EventTPoolManager this, int fd, int *has_fd) | 
| search insert place, to use event_tpool_thread_insert_thread  More... | |
This is API implement for EventTPoolManager class.
Definition in file event_tpool_manager.c.
| #define _GNU_SOURCE | 
Definition at line 5 of file event_tpool_manager.c.
| #define EV_TPOLL_FD | ( | place, | |
| place_u8, | |||
| index | |||
| ) | (index + ((place)*EV_TPOLL_USABLE_BITSIZE) + ((place_u8) * EV_TPOLL_U8_BITSIZE) + EV_TPOLL_FD_START) | 
Definition at line 102 of file event_tpool_manager.c.
| #define EV_TPOLL_FD_START (3) | 
Definition at line 97 of file event_tpool_manager.c.
| #define EV_TPOLL_FDINDEX | ( | fd, | |
| place | |||
| ) | ((fd) - ((place)*EV_TPOLL_USABLE_BITSIZE) - EV_TPOLL_FD_START) | 
Definition at line 100 of file event_tpool_manager.c.
| #define EV_TPOLL_FDINDEX_U8 | ( | fd, | |
| place, | |||
| place_u8 | |||
| ) | (EV_TPOLL_FDINDEX(fd,place) - ((place_u8) * EV_TPOLL_U8_BITSIZE)) | 
Definition at line 101 of file event_tpool_manager.c.
| #define EV_TPOLL_FDSU64PLACE | ( | fd | ) | (((fd)-EV_TPOLL_FD_START)/EV_TPOLL_U64_BITSIZE) | 
Definition at line 99 of file event_tpool_manager.c.
| #define EV_TPOLL_U64_BITSIZE (64) | 
thread instance and fd list
Definition at line 23 of file event_tpool_manager.c.
| #define EV_TPOLL_U8_BITSIZE (8) | 
Definition at line 24 of file event_tpool_manager.c.
| #define EV_TPOLL_USABLE_BITSIZE (64) | 
Definition at line 25 of file event_tpool_manager.c.
| #define EVT_TPOOL_MNG_LOCK | ( | this | ) | DPUTIL_LOCK(this->lock); | 
Definition at line 77 of file event_tpool_manager.c.
| #define EVT_TPOOL_MNG_UNLOCK DPUTIL_UNLOCK; | 
Definition at line 78 of file event_tpool_manager.c.
| typedef union data_fds_u data_fds_u | 
Definition at line 36 of file event_tpool_manager.c.
| typedef struct event_tpool_thread_info_t event_tpool_thread_info_t | 
      
  | 
  static | 
| 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.


      
  | 
  static | 
Definition at line 138 of file event_tpool_manager.c.


      
  | 
  static | 
free fddata
Definition at line 155 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.

      
  | 
  static | 
Definition at line 237 of file event_tpool_manager.c.


      
  | 
  static | 
| 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.


      
  | 
  static | 
search insert place, to use event_tpool_thread_insert_thread
Definition at line 250 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.

      
  | 
  static | 
delete thread
Definition at line 177 of file event_tpool_manager.c.


      
  | 
  static | 
search current setting
Definition at line 134 of file event_tpool_manager.c.


      
  | 
  static | 
free thread info
Definition at line 227 of file event_tpool_manager.c.


      
  | 
  static | 
new thread info
Definition at line 185 of file event_tpool_manager.c.


      
  | 
  static | 
start thread
Definition at line 164 of file event_tpool_manager.c.


      
  | 
  static | 
stop thread
Definition at line 169 of file event_tpool_manager.c.


      
  | 
  static | 
Definition at line 129 of file event_tpool_manager.c.


      
  | 
  static | 
      
  | 
  static | 
      
  | 
  static | 
| 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.
