design_pattern_for_c
V 1.00
|
This is API implement for EventThread class. More...
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/eventfd.h>
#include <errno.h>
#include <sys/stat.h>
#include <dlfcn.h>
#include "event_thread.h"
#include "tpool_event_if.h"
#include "dp_util.h"
#include "config.h"
Go to the source code of this file.
Data Structures | |
struct | event_thread_msg_body_add_t |
message definition for manage subscriber More... | |
struct | event_thread_msg_body_del_t |
struct | event_thread_msg_t |
message struct definition More... | |
struct | event_thread_msg_info_t |
struct | event_subscriber_data_t |
subscriber information define More... | |
struct | event_tpool_thread_t |
thread information More... | |
Macros | |
#define | EVENT_THREAD_WAIT_TIMEOUT (2)/*sec*/ |
#define | EVENT_THREAD_STACKSIZE (256 * 1024)/*suitable stack size*/ |
API for message. | |
#define | EVMSG_LOCK(this) DPUTIL_LOCK(&this->msgdata.lock); |
#define | EVMSG_UNLOCK DPUTIL_UNLOCK |
static int | event_thread_msg_send (EventTPoolThread this, EventThreadMsg msg) |
static int | event_thread_msg_send_without_lock (EventTPoolThread this, EventThreadMsg msg) |
static void | event_thread_msg_send_subscribe (EventTPoolThread this, EventSubscriber subscriber, void *arg, int type) |
static void | event_thread_msg_send_add (EventTPoolThread this, EventSubscriber subscriber, void *arg) |
static void | event_thread_msg_send_update (EventTPoolThread this, EventSubscriber subscriber, void *arg) |
static void | event_thread_msg_send_del (EventTPoolThread this, int fd) |
static int | event_thread_msg_send_stop (EventTPoolThread this) |
API for EventTPoolThread msg callback | |
typedef void(* | event_tpool_thread_msg_cb) (EventTPoolThread this, event_thread_msg_t *msg) |
static event_tpool_thread_msg_cb | event_tpool_thread_msg_cb_table [] |
callback table More... | |
static void | event_tpool_thread_msg_cb_add (EventTPoolThread this, event_thread_msg_t *msg) |
for add More... | |
static void | event_tpool_thread_msg_cb_update (EventTPoolThread this, event_thread_msg_t *msg) |
for update More... | |
static void | event_tpool_thread_msg_cb_del (EventTPoolThread this, event_thread_msg_t *msg) |
for del More... | |
static void | event_tpool_thread_msg_cb_stop (EventTPoolThread this, event_thread_msg_t *msg) |
for stop More... | |
static void | event_tpool_thread_msg_cb_call (EventTPoolThread this, event_thread_msg_t *msg) |
static void | event_tpool_thread_call_msgs (EventTPoolThread this, eventfd_t cnt) |
main messages caller More... | |
static void | event_tpool_thread_cb (int, int, void *) |
callback main More... | |
This is API implement for EventThread class.
Definition in file event_thread.c.
#define event_thread_pop | ( | this | ) | (EventSubscriberData)dputil_list_pop((DPUtilList)(this)) |
Definition at line 100 of file event_thread.c.
#define event_thread_pull | ( | this, | |
data | |||
) | dputil_list_pull((DPUtilList)(this), (DPUtilListData)(data)) |
Definition at line 101 of file event_thread.c.
#define event_thread_push | ( | this, | |
data | |||
) | dputil_list_push((DPUtilList)(this), (DPUtilListData)(data)) |
Definition at line 102 of file event_thread.c.
#define EVENT_THREAD_STACKSIZE (256 * 1024)/*suitable stack size*/ |
Definition at line 21 of file event_thread.c.
#define EVENT_THREAD_WAIT_TIMEOUT (2)/*sec*/ |
Definition at line 19 of file event_thread.c.
#define EVMSG_LOCK | ( | this | ) | DPUTIL_LOCK(&this->msgdata.lock); |
Definition at line 122 of file event_thread.c.
#define EVMSG_UNLOCK DPUTIL_UNLOCK |
Definition at line 123 of file event_thread.c.
typedef struct event_thread_msg_body_add_t event_thread_msg_body_add_t |
message definition for manage subscriber
typedef struct event_thread_msg_body_del_t event_thread_msg_body_del_t |
typedef struct event_thread_msg_info_t event_thread_msg_info_t |
typedef struct event_thread_msg_t event_thread_msg_t |
Definition at line 61 of file event_thread.c.
typedef void(* event_tpool_thread_msg_cb) (EventTPoolThread this, event_thread_msg_t *msg) |
Definition at line 156 of file event_thread.c.
typedef struct event_subscriber_data_t* EventSubscriberData |
subscriber information define
Definition at line 92 of file event_thread.c.
typedef struct event_thread_msg_t * EventThreadMsg |
Definition at line 61 of file event_thread.c.
|
static |
free instance
Definition at line 314 of file event_thread.c.
|
static |
|
static |
new instance
Definition at line 293 of file event_thread.c.
void event_thread_atfork_child | ( | EventTPoolThread | this | ) |
|
static |
|
static |
Definition at line 230 of file event_thread.c.
|
static |
Definition at line 240 of file event_thread.c.
|
static |
Definition at line 263 of file event_thread.c.
|
static |
Definition at line 209 of file event_thread.c.
|
static |
Definition at line 236 of file event_thread.c.
|
static |
|
static |
void event_thread_set_stack_size | ( | size_t | stack_size | ) |
void event_tpool_thread_add | ( | EventTPoolThread | this, |
EventSubscriber | subscriber, | ||
void * | arg | ||
) |
add new subscriber
Definition at line 601 of file event_thread.c.
|
static |
main messages caller
Definition at line 455 of file event_thread.c.
|
static |
callback main
Definition at line 469 of file event_thread.c.
void event_tpool_thread_del | ( | EventTPoolThread | this, |
int | fd | ||
) |
delete subscriber
Definition at line 609 of file event_thread.c.
|
static |
free thread instance, please call stop before calling it
Definition at line 362 of file event_thread.c.
|
static |
|
static |
get subscriber
Definition at line 373 of file event_thread.c.
|
static |
int event_tpool_thread_load_plugin | ( | const char * | plugin_path | ) |
Definition at line 623 of file event_thread.c.
|
static |
main thread
Definition at line 385 of file event_thread.c.
|
static |
|
static |
|
static |
|
static |
for stop
Definition at line 449 of file event_thread.c.
|
static |
EventTPoolThread event_tpool_thread_new | ( | size_t | thread_size | ) |
create and thread instance
Definition at line 537 of file event_thread.c.
|
static |
remove event_base
Definition at line 352 of file event_thread.c.
|
static |
set event_base
Definition at line 330 of file event_thread.c.
void event_tpool_thread_start | ( | EventTPoolThread | this | ) |
start thread
Definition at line 569 of file event_thread.c.
void event_tpool_thread_stop | ( | EventTPoolThread | this | ) |
stop thread
stop thread, and remove resource
Definition at line 585 of file event_thread.c.
int event_tpool_thread_unload_plugin | ( | void | ) |
void event_tpool_thread_update | ( | EventTPoolThread | this, |
EventSubscriber | subscriber, | ||
void * | arg | ||
) |
update subscriber
Definition at line 604 of file event_thread.c.
EventHandler(* add) (EventInstance this, EventSubscriber subscriber, void *arg) |
Definition at line 32 of file event_thread.c.
void(* del) (EventInstance this, EventHandler handler) |
Definition at line 34 of file event_thread.c.
struct { ... } event_if_instance_g |
interface definition
|
static |
thread stack size, user can change it by using event_tpool_set_stack_size
Definition at line 47 of file event_thread.c.
|
static |
callback table
Definition at line 166 of file event_thread.c.
void(* exit) (EventInstance this) |
Definition at line 38 of file event_thread.c.
void(* free) (EventInstance this) |
Definition at line 39 of file event_thread.c.
int(* getfd) (EventHandler handler) |
Definition at line 35 of file event_thread.c.
void* handle |
Definition at line 30 of file event_thread.c.
int(* loop) (EventInstance this) |
Definition at line 36 of file event_thread.c.
void(* loopbreak) (EventInstance this) |
Definition at line 37 of file event_thread.c.
EventInstance(* new) (void) |
Definition at line 31 of file event_thread.c.
EventHandler(* update) (EventInstance this, EventHandler handler, EventSubscriber subscriber, void *arg) |
Definition at line 33 of file event_thread.c.