2004-09-28 03:34:51 -05:00
|
|
|
|
|
|
|
/*
|
2004-09-29 11:00:49 -05:00
|
|
|
* Copyright (C) Igor Sysoev
|
2012-01-18 09:07:43 -06:00
|
|
|
* Copyright (C) Nginx, Inc.
|
2004-09-28 03:34:51 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2004-04-04 15:32:09 -05:00
|
|
|
#ifndef _NGX_EVENT_POSTED_H_INCLUDED_
|
|
|
|
#define _NGX_EVENT_POSTED_H_INCLUDED_
|
|
|
|
|
|
|
|
|
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
|
|
|
#include <ngx_event.h>
|
|
|
|
|
|
|
|
|
2005-10-19 07:33:58 -05:00
|
|
|
#if (NGX_THREADS)
|
|
|
|
extern ngx_mutex_t *ngx_posted_events_mutex;
|
|
|
|
#endif
|
2004-07-02 10:54:34 -05:00
|
|
|
|
2005-10-19 07:33:58 -05:00
|
|
|
|
|
|
|
#define ngx_locked_post_event(ev, queue) \
|
|
|
|
\
|
|
|
|
if (ev->prev == NULL) { \
|
|
|
|
ev->next = (ngx_event_t *) *queue; \
|
|
|
|
ev->prev = (ngx_event_t **) queue; \
|
|
|
|
*queue = ev; \
|
|
|
|
\
|
2004-07-02 10:54:34 -05:00
|
|
|
if (ev->next) { \
|
2005-10-19 07:33:58 -05:00
|
|
|
ev->next->prev = &ev->next; \
|
2004-07-02 10:54:34 -05:00
|
|
|
} \
|
2005-10-19 07:33:58 -05:00
|
|
|
\
|
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, "post event %p", ev); \
|
|
|
|
\
|
|
|
|
} else { \
|
2004-07-05 10:08:23 -05:00
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, \
|
2005-10-19 07:33:58 -05:00
|
|
|
"update posted event %p", ev); \
|
|
|
|
}
|
2004-07-02 10:54:34 -05:00
|
|
|
|
2004-06-30 10:30:41 -05:00
|
|
|
|
2005-10-19 07:33:58 -05:00
|
|
|
#define ngx_post_event(ev, queue) \
|
|
|
|
\
|
|
|
|
ngx_mutex_lock(ngx_posted_events_mutex); \
|
|
|
|
ngx_locked_post_event(ev, queue); \
|
|
|
|
ngx_mutex_unlock(ngx_posted_events_mutex);
|
2004-04-04 15:32:09 -05:00
|
|
|
|
|
|
|
|
2005-10-19 07:33:58 -05:00
|
|
|
#define ngx_delete_posted_event(ev) \
|
|
|
|
\
|
|
|
|
*(ev->prev) = ev->next; \
|
|
|
|
\
|
|
|
|
if (ev->next) { \
|
|
|
|
ev->next->prev = ev->prev; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
ev->prev = NULL; \
|
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_CORE, ev->log, 0, \
|
|
|
|
"delete posted event %p", ev);
|
2004-06-27 13:01:57 -05:00
|
|
|
|
|
|
|
|
2005-10-19 07:33:58 -05:00
|
|
|
|
|
|
|
void ngx_event_process_posted(ngx_cycle_t *cycle,
|
|
|
|
ngx_thread_volatile ngx_event_t **posted);
|
|
|
|
void ngx_wakeup_worker_thread(ngx_cycle_t *cycle);
|
|
|
|
|
2004-04-04 15:32:09 -05:00
|
|
|
#if (NGX_THREADS)
|
2004-06-27 13:01:57 -05:00
|
|
|
ngx_int_t ngx_event_thread_process_posted(ngx_cycle_t *cycle);
|
2004-04-04 15:32:09 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2005-10-19 07:33:58 -05:00
|
|
|
extern ngx_thread_volatile ngx_event_t *ngx_posted_accept_events;
|
|
|
|
extern ngx_thread_volatile ngx_event_t *ngx_posted_events;
|
|
|
|
|
|
|
|
|
2004-04-04 15:32:09 -05:00
|
|
|
#endif /* _NGX_EVENT_POSTED_H_INCLUDED_ */
|