static pthread_mutex_t masters_mtx = PTHREAD_MUTEX_INITIALIZER;
static struct list *masters;
-static void thread_free(struct event_master *master, struct event *thread);
+static void thread_free(struct event_loop *master, struct event *thread);
#ifndef EXCLUDE_CPU_TIME
#define EXCLUDE_CPU_TIME 0
{
struct cpu_event_history tmp;
void *args[3] = {&tmp, vty, &filter};
- struct event_master *m;
+ struct event_loop *m;
struct listnode *ln;
if (!cputime_enabled)
static void cpu_record_clear(uint8_t filter)
{
uint8_t *tmp = &filter;
- struct event_master *m;
+ struct event_loop *m;
struct listnode *ln;
frr_with_mutex (&masters_mtx) {
"Set up miscellaneous service\n"
"Warn for tasks exceeding total wallclock threshold\n")
-static void show_thread_poll_helper(struct vty *vty, struct event_master *m)
+static void show_thread_poll_helper(struct vty *vty, struct event_loop *m)
{
const char *name = m->name ? m->name : "main";
char underline[strlen(name) + 1];
"Show poll FD's and information\n")
{
struct listnode *node;
- struct event_master *m;
+ struct event_loop *m;
frr_with_mutex (&masters_mtx) {
for (ALL_LIST_ELEMENTS_RO(masters, node, m)) {
return CMD_SUCCESS;
}
-static void show_thread_timers_helper(struct vty *vty, struct event_master *m)
+static void show_thread_timers_helper(struct vty *vty, struct event_loop *m)
{
const char *name = m->name ? m->name : "main";
char underline[strlen(name) + 1];
"Show all timers and how long they have in the system\n")
{
struct listnode *node;
- struct event_master *m;
+ struct event_loop *m;
frr_with_mutex (&masters_mtx) {
for (ALL_LIST_ELEMENTS_RO(masters, node, m))
pthread_key_create(&thread_current, NULL);
}
-struct event_master *thread_master_create(const char *name)
+struct event_loop *event_master_create(const char *name)
{
- struct event_master *rv;
+ struct event_loop *rv;
struct rlimit limit;
pthread_once(&init_once, &initializer);
- rv = XCALLOC(MTYPE_EVENT_MASTER, sizeof(struct event_master));
+ rv = XCALLOC(MTYPE_EVENT_MASTER, sizeof(struct event_loop));
/* Initialize master mutex */
pthread_mutex_init(&rv->mtx, NULL);
return rv;
}
-void thread_master_set_name(struct event_master *master, const char *name)
+void event_master_set_name(struct event_loop *master, const char *name)
{
frr_with_mutex (&master->mtx) {
XFREE(MTYPE_EVENT_MASTER, master->name);
#define EVENT_UNUSED_DEPTH 10
/* Move thread to unuse list. */
-static void thread_add_unuse(struct event_master *m, struct event *thread)
+static void thread_add_unuse(struct event_loop *m, struct event *thread)
{
pthread_mutex_t mtxc = thread->mtx;
}
/* Free all unused thread. */
-static void thread_list_free(struct event_master *m,
- struct event_list_head *list)
+static void thread_list_free(struct event_loop *m, struct event_list_head *list)
{
struct event *t;
thread_free(m, t);
}
-static void thread_array_free(struct event_master *m,
- struct event **thread_array)
+static void thread_array_free(struct event_loop *m, struct event **thread_array)
{
struct event *t;
int index;
}
/*
- * thread_master_free_unused
+ * event_master_free_unused
*
* As threads are finished with they are put on the
* unuse list for later reuse.
* If we are shutting down, Free up unused threads
* So we can see if we forget to shut anything off
*/
-void thread_master_free_unused(struct event_master *m)
+void event_master_free_unused(struct event_loop *m)
{
frr_with_mutex (&m->mtx) {
struct event *t;
}
/* Stop thread scheduler. */
-void thread_master_free(struct event_master *m)
+void event_master_free(struct event_loop *m)
{
struct event *t;
}
/* Get new thread. */
-static struct event *thread_get(struct event_master *m, uint8_t type,
+static struct event *thread_get(struct event_loop *m, uint8_t type,
void (*func)(struct event *), void *arg,
const struct xref_eventsched *xref)
{
return thread;
}
-static void thread_free(struct event_master *master, struct event *thread)
+static void thread_free(struct event_loop *master, struct event *thread)
{
/* Update statistics. */
assert(master->alloc > 0);
XFREE(MTYPE_THREAD, thread);
}
-static int fd_poll(struct event_master *m, const struct timeval *timer_wait,
+static int fd_poll(struct event_loop *m, const struct timeval *timer_wait,
bool *eintr_p)
{
sigset_t origsigs;
/*
* If timer_wait is null here, that means poll() should block
- * indefinitely, unless the thread_master has overridden it by setting
+ * indefinitely, unless the event_master has overridden it by setting
* ->selectpoll_timeout.
*
* If the value is positive, it specifies the maximum number of
/* Add new read thread. */
void _event_add_read_write(const struct xref_eventsched *xref,
- struct event_master *m, void (*func)(struct event *),
+ struct event_loop *m, void (*func)(struct event *),
void *arg, int fd, struct event **t_ptr)
{
int dir = xref->event_type;
}
static void _event_add_timer_timeval(const struct xref_eventsched *xref,
- struct event_master *m,
+ struct event_loop *m,
void (*func)(struct event *), void *arg,
struct timeval *time_relative,
struct event **t_ptr)
/* Add timer event thread. */
-void _event_add_timer(const struct xref_eventsched *xref,
- struct event_master *m, void (*func)(struct event *),
- void *arg, long timer, struct event **t_ptr)
+void _event_add_timer(const struct xref_eventsched *xref, struct event_loop *m,
+ void (*func)(struct event *), void *arg, long timer,
+ struct event **t_ptr)
{
struct timeval trel;
/* Add timer event thread with "millisecond" resolution */
void _event_add_timer_msec(const struct xref_eventsched *xref,
- struct event_master *m, void (*func)(struct event *),
+ struct event_loop *m, void (*func)(struct event *),
void *arg, long timer, struct event **t_ptr)
{
struct timeval trel;
/* Add timer event thread with "timeval" resolution */
void _event_add_timer_tv(const struct xref_eventsched *xref,
- struct event_master *m, void (*func)(struct event *),
+ struct event_loop *m, void (*func)(struct event *),
void *arg, struct timeval *tv, struct event **t_ptr)
{
_event_add_timer_timeval(xref, m, func, arg, tv, t_ptr);
}
/* Add simple event thread. */
-void _event_add_event(const struct xref_eventsched *xref,
- struct event_master *m, void (*func)(struct event *),
- void *arg, int val, struct event **t_ptr)
+void _event_add_event(const struct xref_eventsched *xref, struct event_loop *m,
+ void (*func)(struct event *), void *arg, int val,
+ struct event **t_ptr)
{
struct event *thread = NULL;
* - POLLIN
* - POLLOUT
*/
-static void event_cancel_rw(struct event_master *master, int fd, short state,
+static void event_cancel_rw(struct event_loop *master, int fd, short state,
int idx_hint)
{
bool found = false;
* Process task cancellation given a task argument: iterate through the
* various lists of tasks, looking for any that match the argument.
*/
-static void cancel_arg_helper(struct event_master *master,
+static void cancel_arg_helper(struct event_loop *master,
const struct cancel_req *cr)
{
struct event *t;
/**
* Process cancellation requests.
*
- * This may only be run from the pthread which owns the thread_master.
+ * This may only be run from the pthread which owns the event_master.
*
* @param master the thread master to process
* @REQUIRE master->mtx
*/
-static void do_event_cancel(struct event_master *master)
+static void do_event_cancel(struct event_loop *master)
{
struct event_list_head *list = NULL;
struct event **thread_array = NULL;
/*
* Helper function used for multiple flavors of arg-based cancellation.
*/
-static void cancel_event_helper(struct event_master *m, void *arg, int flags)
+static void cancel_event_helper(struct event_loop *m, void *arg, int flags)
{
struct cancel_req *cr;
*
* MT-Unsafe
*
- * @param m the thread_master to cancel from
+ * @param m the event_master to cancel from
* @param arg the argument passed when creating the event
*/
-void event_cancel_event(struct event_master *master, void *arg)
+void event_cancel_event(struct event_loop *master, void *arg)
{
cancel_event_helper(master, arg, 0);
}
*
* MT-Unsafe
*
- * @param m the thread_master to cancel from
+ * @param m the event_master to cancel from
* @param arg the argument passed when creating the event
*/
-void event_cancel_event_ready(struct event_master *m, void *arg)
+void event_cancel_event_ready(struct event_loop *m, void *arg)
{
/* Only cancel ready/event tasks */
*/
void event_cancel(struct event **thread)
{
- struct event_master *master;
+ struct event_loop *master;
if (thread == NULL || *thread == NULL)
return;
* The last two parameters are mutually exclusive, i.e. if you pass one the
* other must be NULL.
*
- * When the cancellation procedure executes on the target thread_master, the
+ * When the cancellation procedure executes on the target event_master, the
* thread * provided is checked for nullity. If it is null, the thread is
* assumed to no longer exist and the cancellation request is a no-op. Thus
* users of this API must pass a back-reference when scheduling the original
* @param thread pointer to thread to cancel
* @param eventobj the event
*/
-void event_cancel_async(struct event_master *master, struct event **thread,
+void event_cancel_async(struct event_loop *master, struct event **thread,
void *eventobj)
{
assert(!(thread && eventobj) && (thread || eventobj));
return timer_val;
}
-static struct event *thread_run(struct event_master *m, struct event *thread,
+static struct event *thread_run(struct event_loop *m, struct event *thread,
struct event *fetch)
{
*fetch = *thread;
return fetch;
}
-static int thread_process_io_helper(struct event_master *m,
- struct event *thread, short state,
- short actual_state, int pos)
+static int thread_process_io_helper(struct event_loop *m, struct event *thread,
+ short state, short actual_state, int pos)
{
struct event **thread_array;
* @param m the thread master
* @param num the number of active file descriptors (return value of poll())
*/
-static void thread_process_io(struct event_master *m, unsigned int num)
+static void thread_process_io(struct event_loop *m, unsigned int num)
{
unsigned int ready = 0;
struct pollfd *pfds = m->handler.copy;
}
/* Add all timers that have popped to the ready list. */
-static unsigned int thread_process_timers(struct event_master *m,
+static unsigned int thread_process_timers(struct event_loop *m,
struct timeval *timenow)
{
struct timeval prev = *timenow;
/* Fetch next ready thread. */
-struct event *event_fetch(struct event_master *m, struct event *fetch)
+struct event *event_fetch(struct event_loop *m, struct event *fetch)
{
struct event *thread = NULL;
struct timeval now;
}
/* Execute thread */
-void _event_execute(const struct xref_eventsched *xref, struct event_master *m,
+void _event_execute(const struct xref_eventsched *xref, struct event_loop *m,
void (*func)(struct event *), void *arg, int val)
{
struct event *thread;