mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
test: move threads created with THREAD_START() to realtime scheduling class too
This commit is contained in:
parent
b1e46c32db
commit
e6285eed62
@ -141,6 +141,7 @@ SSL_CTX *get_ssl_ctx(void);
|
||||
void init_ssl(void);
|
||||
#endif
|
||||
|
||||
void thread_setup(pthread_t pthread);
|
||||
void * basic_test_setup(const struct testcase_t *testcase);
|
||||
int basic_test_cleanup(const struct testcase_t *testcase, void *ptr);
|
||||
|
||||
|
@ -223,6 +223,13 @@ void move_pthread_to_realtime_scheduling_class(pthread_t pthread)
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void thread_setup(pthread_t pthread)
|
||||
{
|
||||
move_pthread_to_realtime_scheduling_class(pthread);
|
||||
}
|
||||
#else
|
||||
void thread_setup(pthread_t pthread) {}
|
||||
#endif
|
||||
|
||||
void *
|
||||
@ -238,9 +245,7 @@ basic_test_setup(const struct testcase_t *testcase)
|
||||
evthread_flags |= EVTHREAD_PTHREAD_PRIO_INHERIT;
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
move_pthread_to_realtime_scheduling_class(pthread_self());
|
||||
#endif
|
||||
thread_setup(pthread_self());
|
||||
|
||||
#ifndef _WIN32
|
||||
if (testcase->flags & TT_ENABLE_IOCP_FLAG)
|
||||
|
@ -27,22 +27,26 @@
|
||||
#ifndef REGRESS_THREAD_H_INCLUDED_
|
||||
#define REGRESS_THREAD_H_INCLUDED_
|
||||
|
||||
#include "regress.h"
|
||||
|
||||
#ifdef EVENT__HAVE_PTHREADS
|
||||
#include <pthread.h>
|
||||
#define THREAD_T pthread_t
|
||||
#define THREAD_FN void *
|
||||
#define THREAD_RETURN() return (NULL)
|
||||
#define THREAD_START(threadvar, fn, arg) \
|
||||
pthread_create(&(threadvar), NULL, fn, arg)
|
||||
#define THREAD_START(threadvar, fn, arg) do { \
|
||||
if (!pthread_create(&(threadvar), NULL, fn, arg)) \
|
||||
thread_setup(threadvar); \
|
||||
} while (0)
|
||||
#define THREAD_JOIN(th) pthread_join(th, NULL)
|
||||
#else
|
||||
#define THREAD_T HANDLE
|
||||
#define THREAD_FN unsigned __stdcall
|
||||
#define THREAD_RETURN() return (0)
|
||||
#define THREAD_START(threadvar, fn, arg) do { \
|
||||
uintptr_t threadhandle = _beginthreadex(NULL,0,fn,(arg),0,NULL); \
|
||||
(threadvar) = (HANDLE) threadhandle; \
|
||||
} while (0)
|
||||
uintptr_t threadhandle = _beginthreadex(NULL,0,fn,(arg),0,NULL); \
|
||||
(threadvar) = (HANDLE) threadhandle; \
|
||||
} while (0)
|
||||
#define THREAD_JOIN(th) WaitForSingleObject(th, INFINITE)
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user