Permalink
Browse files

Replace more deferred_cb names with event_callback

  • Loading branch information...
1 parent ae2b84b commit a4079aa88a5d4bd70ad3c74f83460e1a0a40772d Nick Mathewson committed Apr 6, 2012
Showing with 32 additions and 40 deletions.
  1. +3 −3 buffer.c
  2. +1 −1 bufferevent-internal.h
  3. +3 −3 bufferevent.c
  4. +5 −10 defer-internal.h
  5. +3 −3 evbuffer-internal.h
  6. +3 −3 evdns.c
  7. +1 −1 event.c
  8. +1 −1 http-internal.h
  9. +2 −2 http.c
  10. +6 −6 listener.c
  11. +4 −7 test/regress_thread.c
View
@@ -142,7 +142,7 @@
static void evbuffer_chain_align(struct evbuffer_chain *chain);
static int evbuffer_chain_should_realign(struct evbuffer_chain *chain,
size_t datalen);
-static void evbuffer_deferred_callback(struct deferred_cb *cb, void *arg);
+static void evbuffer_deferred_callback(struct event_callback *cb, void *arg);
static int evbuffer_ptr_memcmp(const struct evbuffer *buf,
const struct evbuffer_ptr *pos, const char *mem, size_t len);
static struct evbuffer_chain *evbuffer_expand_singlechain(struct evbuffer *buf,
@@ -402,7 +402,7 @@ int
evbuffer_defer_callbacks(struct evbuffer *buffer, struct event_base *base)
{
EVBUFFER_LOCK(buffer);
- buffer->cb_queue = event_base_get_deferred_cb_queue_(base);
+ buffer->cb_queue = base;
buffer->deferred_cbs = 1;
event_deferred_cb_init_(base, &buffer->deferred,
evbuffer_deferred_callback, buffer);
@@ -521,7 +521,7 @@ evbuffer_invoke_callbacks_(struct evbuffer *buffer)
}
static void
-evbuffer_deferred_callback(struct deferred_cb *cb, void *arg)
+evbuffer_deferred_callback(struct event_callback *cb, void *arg)
{
struct bufferevent *parent = NULL;
struct evbuffer *buffer = arg;
View
@@ -183,7 +183,7 @@ struct bufferevent_private {
int dns_error;
/** Used to implement deferred callbacks */
- struct deferred_cb deferred;
+ struct event_callback deferred;
/** The options this bufferevent was constructed with */
enum bufferevent_options options;
View
@@ -131,7 +131,7 @@ bufferevent_inbuf_wm_cb(struct evbuffer *buf,
}
static void
-bufferevent_run_deferred_callbacks_locked(struct deferred_cb *cb, void *arg)
+bufferevent_run_deferred_callbacks_locked(struct event_callback *cb, void *arg)
{
struct bufferevent_private *bufev_private = arg;
struct bufferevent *bufev = &bufev_private->bev;
@@ -164,7 +164,7 @@ bufferevent_run_deferred_callbacks_locked(struct deferred_cb *cb, void *arg)
}
static void
-bufferevent_run_deferred_callbacks_unlocked(struct deferred_cb *cb, void *arg)
+bufferevent_run_deferred_callbacks_unlocked(struct event_callback *cb, void *arg)
{
struct bufferevent_private *bufev_private = arg;
struct bufferevent *bufev = &bufev_private->bev;
@@ -211,7 +211,7 @@ bufferevent_run_deferred_callbacks_unlocked(struct deferred_cb *cb, void *arg)
#define SCHEDULE_DEFERRED(bevp) \
do { \
if (event_deferred_cb_schedule_( \
- event_base_get_deferred_cb_queue_((bevp)->bev.ev_base), \
+ (bevp)->bev.ev_base, \
&(bevp)->deferred)) \
bufferevent_incref_(&(bevp)->bev); \
} while (0)
View
@@ -35,26 +35,23 @@ extern "C" {
#include <sys/queue.h>
-#define deferred_cb event_callback
-#define deferred_cb_queue event_base
struct event_callback;
-
typedef void (*deferred_cb_fn)(struct event_callback *, void *);
/**
- Initialize an empty, non-pending deferred_cb.
+ Initialize an empty, non-pending event_callback.
- @param deferred The deferred_cb structure to initialize.
- @param cb The function to run when the deferred_cb executes.
+ @param deferred The struct event_callback structure to initialize.
+ @param cb The function to run when the struct event_callback executes.
@param arg The function's second argument.
*/
void event_deferred_cb_init_(struct event_base *base, struct event_callback *, deferred_cb_fn, void *);
/**
- Cancel a deferred_cb if it is currently scheduled in an event_base.
+ Cancel a struct event_callback if it is currently scheduled in an event_base.
*/
void event_deferred_cb_cancel_(struct event_base *, struct event_callback *);
/**
- Activate a deferred_cb if it is not currently scheduled in an event_base.
+ Activate a struct event_callback if it is not currently scheduled in an event_base.
Return true iff it was not previously scheduled.
*/
@@ -64,7 +61,5 @@ int event_deferred_cb_schedule_(struct event_base *, struct event_callback *);
}
#endif
-#define event_base_get_deferred_cb_queue_(x) (x)
-
#endif /* EVENT_INTERNAL_H_INCLUDED_ */
View
@@ -135,17 +135,17 @@ struct evbuffer {
ev_uint32_t flags;
/** Used to implement deferred callbacks. */
- struct deferred_cb_queue *cb_queue;
+ struct event_base *cb_queue;
/** A reference count on this evbuffer. When the reference count
* reaches 0, the buffer is destroyed. Manipulated with
* evbuffer_incref and evbuffer_decref_and_unlock and
* evbuffer_free. */
int refcnt;
- /** A deferred_cb handle to make all of this buffer's callbacks
+ /** A struct event_callback handle to make all of this buffer's callbacks
* invoked from the event loop. */
- struct deferred_cb deferred;
+ struct event_callback deferred;
/** A doubly-linked-list of callback functions */
LIST_HEAD(evbuffer_cb_queue, evbuffer_cb_entry) callbacks;
View
@@ -754,7 +754,7 @@ evdns_requests_pump_waiting_queue(struct evdns_base *base) {
/* TODO(nickm) document */
struct deferred_reply_callback {
- struct deferred_cb deferred;
+ struct event_callback deferred;
struct evdns_request *handle;
u8 request_type;
u8 have_reply;
@@ -765,7 +765,7 @@ struct deferred_reply_callback {
};
static void
-reply_run_callback(struct deferred_cb *d, void *user_pointer)
+reply_run_callback(struct event_callback *d, void *user_pointer)
{
struct deferred_reply_callback *cb =
EVUTIL_UPCAST(d, struct deferred_reply_callback, deferred);
@@ -840,7 +840,7 @@ reply_schedule_callback(struct request *const req, u32 ttl, u32 err, struct repl
&d->deferred, reply_run_callback,
req->user_pointer);
event_deferred_cb_schedule_(
- event_base_get_deferred_cb_queue_(req->base->event_base),
+ req->base->event_base,
&d->deferred);
}
View
@@ -2128,7 +2128,7 @@ evthread_notify_base_eventfd(struct event_base *base)
/** Tell the thread currently running the event_loop for base (if any) that it
* needs to stop waiting in its dispatch function (if it is) and process all
- * active events and deferred callbacks (if there are any). */
+ * active callbacks. */
static int
evthread_notify_base(struct event_base *base)
{
View
@@ -103,7 +103,7 @@ struct evhttp_connection {
void (*closecb)(struct evhttp_connection *, void *);
void *closecb_arg;
- struct deferred_cb read_more_deferred_cb;
+ struct event_callback read_more_deferred_cb;
struct event_base *base;
struct evdns_base *dns_base;
View
4 http.c
@@ -1017,7 +1017,7 @@ evhttp_read_body(struct evhttp_connection *evcon, struct evhttp_request *req)
}
#define get_deferred_queue(evcon) \
- (event_base_get_deferred_cb_queue_((evcon)->base))
+ ((evcon)->base)
/*
* Gets called when more data becomes available
@@ -1079,7 +1079,7 @@ evhttp_read_cb(struct bufferevent *bufev, void *arg)
}
static void
-evhttp_deferred_read_cb(struct deferred_cb *cb, void *data)
+evhttp_deferred_read_cb(struct event_callback *cb, void *data)
{
struct evhttp_connection *evcon = data;
evhttp_read_cb(evcon->bufev, evcon);
View
@@ -440,7 +440,7 @@ struct accepting_socket {
struct event_overlapped overlapped;
SOCKET s;
int error;
- struct deferred_cb deferred;
+ struct event_callback deferred;
struct evconnlistener_iocp *lev;
ev_uint8_t buflen;
ev_uint8_t family;
@@ -450,7 +450,7 @@ struct accepting_socket {
static void accepted_socket_cb(struct event_overlapped *o, ev_uintptr_t key,
ev_ssize_t n, int ok);
-static void accepted_socket_invoke_user_cb(struct deferred_cb *cb, void *arg);
+static void accepted_socket_invoke_user_cb(struct event_callback *cb, void *arg);
static void
iocp_listener_event_add(struct evconnlistener_iocp *lev)
@@ -566,7 +566,7 @@ start_accepting(struct accepting_socket *as)
report_err:
as->error = error;
event_deferred_cb_schedule_(
- event_base_get_deferred_cb_queue_(as->lev->event_base),
+ as->lev->event_base,
&as->deferred);
return 0;
}
@@ -581,7 +581,7 @@ stop_accepting(struct accepting_socket *as)
}
static void
-accepted_socket_invoke_user_cb(struct deferred_cb *dcb, void *arg)
+accepted_socket_invoke_user_cb(struct event_callback *dcb, void *arg)
{
struct accepting_socket *as = arg;
@@ -658,7 +658,7 @@ accepted_socket_cb(struct event_overlapped *o, ev_uintptr_t key, ev_ssize_t n, i
if (ok) {
/* XXXX Don't do this if some EV_MT flag is set. */
event_deferred_cb_schedule_(
- event_base_get_deferred_cb_queue_(as->lev->event_base),
+ as->lev->event_base,
&as->deferred);
LeaveCriticalSection(&as->lock);
} else if (as->free_on_cb) {
@@ -683,7 +683,7 @@ accepted_socket_cb(struct event_overlapped *o, ev_uintptr_t key, ev_ssize_t n, i
as->error = WSAGetLastError();
}
event_deferred_cb_schedule_(
- event_base_get_deferred_cb_queue_(as->lev->event_base),
+ as->lev->event_base,
&as->deferred);
LeaveCriticalSection(&as->lock);
}
View
@@ -415,8 +415,8 @@ SLEEP_MS(int ms)
}
struct deferred_test_data {
- struct deferred_cb cbs[CB_COUNT];
- struct deferred_cb_queue *queue;
+ struct event_callback cbs[CB_COUNT];
+ struct event_base *queue;
};
static struct timeval timer_start = {0,0};
@@ -426,7 +426,7 @@ static THREAD_T load_threads[QUEUE_THREAD_COUNT];
static struct deferred_test_data deferred_data[QUEUE_THREAD_COUNT];
static void
-deferred_callback(struct deferred_cb *cb, void *arg)
+deferred_callback(struct event_callback *cb, void *arg)
{
SLEEP_MS(1);
callback_count += 1;
@@ -469,14 +469,11 @@ thread_deferred_cb_skew(void *arg)
{
struct basic_test_data *data = arg;
struct timeval tv_timer = {1, 0};
- struct deferred_cb_queue *queue;
+ struct event_base *queue = data->base;
struct timeval elapsed;
int elapsed_usec;
int i;
- queue = event_base_get_deferred_cb_queue_(data->base);
- tt_assert(queue);
-
for (i = 0; i < QUEUE_THREAD_COUNT; ++i)
deferred_data[i].queue = queue;

0 comments on commit a4079aa

Please sign in to comment.