9 static void event_publish(
int socketfd,
int eventflag,
void * event_arg) {
12 read(socketfd, buf,
sizeof(buf));
22 fprintf(stderr,
"enter publisher_notify\n");
23 char * str = (
char *)detail;
24 char * str_ctx = (
char *)ctx;
25 printf(
"input:%s(context:%s)\n", str, str_ctx);
29 int maxfd=1, ret = 0;;
36 ret = select(maxfd+1, NULL, NULL, NULL, NULL);
EventTPoolManager event_tpool_manager_new(int thread_num, int is_threadsafe, const char *plugin_path)
new EventTPoolManager
SubscriberAccount publisher_subscribe(int content_id, int publish_type, void(*notify)(int publish_type, void *detail, void *ctx), void *ctx)
subscribe
static void event_publish(int socketfd, int eventflag, void *event_arg)
This is API as ThreadPool design petten by using libevent.
event_tpool_add_result_t event_tpool_add(EventTPoolManager this, EventSubscriber subscriber, void *arg)
add EventSubscriber to threadpool
int publisher_new(size_t contents_num)
new Publisher content, user can get notify to subscribe.
EventTPoolManager class instance definition.
void publisher_publish(int content_id, int publish_type, void *detail)
publish, Publisher call subscriber's notify if type is same
EventSubscriber class instance definition, this is storaged in any threads.
static void add_event_publisher(EventTPoolManager tpool)
void publisher_notify(int publish_type, void *detail, void *ctx)
This is API as Observer(Publish-Subscribe) design petten.