mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-05-05 09:18:10 +00:00
CLEANUP: thread: uninline ha_tkill/ha_tkillall/ha_cpu_relax()
These ones are rarely used or only to waste CPU cycles waiting, and are the last ones requiring system includes in thread.h. Let's uninline them and move them to thread.c.
This commit is contained in:
parent
5e03dfaaf6
commit
aa992761d8
@ -23,12 +23,6 @@
|
||||
#ifndef _HAPROXY_THREAD_H
|
||||
#define _HAPROXY_THREAD_H
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
#include <haproxy/api.h>
|
||||
#include <haproxy/thread-t.h>
|
||||
#include <haproxy/tinfo.h>
|
||||
@ -46,6 +40,9 @@
|
||||
|
||||
/* Generic exports */
|
||||
int parse_nbthread(const char *arg, char **err);
|
||||
void ha_tkill(unsigned int thr, int sig);
|
||||
void ha_tkillall(int sig);
|
||||
void ha_thread_relax(void);
|
||||
extern int thread_cpus_enabled_at_boot;
|
||||
|
||||
|
||||
@ -95,25 +92,6 @@ static inline void ha_set_tid(unsigned int tid)
|
||||
ti = &ha_thread_info[tid];
|
||||
}
|
||||
|
||||
static inline void ha_thread_relax(void)
|
||||
{
|
||||
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||
sched_yield();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* send signal <sig> to thread <thr> */
|
||||
static inline void ha_tkill(unsigned int thr, int sig)
|
||||
{
|
||||
raise(sig);
|
||||
}
|
||||
|
||||
/* send signal <sig> to all threads */
|
||||
static inline void ha_tkillall(int sig)
|
||||
{
|
||||
raise(sig);
|
||||
}
|
||||
|
||||
static inline void thread_idle_now()
|
||||
{
|
||||
}
|
||||
@ -179,8 +157,6 @@ void thread_isolate(void);
|
||||
void thread_isolate_full(void);
|
||||
void thread_release(void);
|
||||
void thread_sync_release(void);
|
||||
void ha_tkill(unsigned int thr, int sig);
|
||||
void ha_tkillall(int sig);
|
||||
void ha_spin_init(HA_SPINLOCK_T *l);
|
||||
void ha_rwlock_init(HA_RWLOCK_T *l);
|
||||
void setup_extra_threads(void *(*handler)(void *));
|
||||
@ -232,15 +208,6 @@ static inline void ha_set_tid(unsigned int data)
|
||||
ti = &ha_thread_info[tid];
|
||||
}
|
||||
|
||||
static inline void ha_thread_relax(void)
|
||||
{
|
||||
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||
sched_yield();
|
||||
#else
|
||||
pl_cpu_relax();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Marks the thread as idle, which means that not only it's not doing anything
|
||||
* dangerous, but in addition it has not started anything sensitive either.
|
||||
* This essentially means that the thread currently is in the poller, thus
|
||||
|
34
src/thread.c
34
src/thread.c
@ -15,6 +15,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_THREAD
|
||||
# include <pthread.h>
|
||||
#endif
|
||||
@ -312,6 +318,15 @@ void ha_tkillall(int sig)
|
||||
raise(sig);
|
||||
}
|
||||
|
||||
void ha_thread_relax(void)
|
||||
{
|
||||
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||
sched_yield();
|
||||
#else
|
||||
pl_cpu_relax();
|
||||
#endif
|
||||
}
|
||||
|
||||
/* these calls are used as callbacks at init time when debugging is on */
|
||||
void ha_spin_init(HA_SPINLOCK_T *l)
|
||||
{
|
||||
@ -956,6 +971,25 @@ static void __thread_init(void)
|
||||
|
||||
#else
|
||||
|
||||
/* send signal <sig> to thread <thr> (send to process in fact) */
|
||||
void ha_tkill(unsigned int thr, int sig)
|
||||
{
|
||||
raise(sig);
|
||||
}
|
||||
|
||||
/* send signal <sig> to all threads (send to process in fact) */
|
||||
void ha_tkillall(int sig)
|
||||
{
|
||||
raise(sig);
|
||||
}
|
||||
|
||||
void ha_thread_relax(void)
|
||||
{
|
||||
#ifdef _POSIX_PRIORITY_SCHEDULING
|
||||
sched_yield();
|
||||
#endif
|
||||
}
|
||||
|
||||
REGISTER_BUILD_OPTS("Built without multi-threading support (USE_THREAD not set).");
|
||||
|
||||
#endif // USE_THREAD
|
||||
|
Loading…
Reference in New Issue
Block a user