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);
|
void init_ssl(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void thread_setup(pthread_t pthread);
|
||||||
void * basic_test_setup(const struct testcase_t *testcase);
|
void * basic_test_setup(const struct testcase_t *testcase);
|
||||||
int basic_test_cleanup(const struct testcase_t *testcase, void *ptr);
|
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);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void thread_setup(pthread_t pthread)
|
||||||
|
{
|
||||||
|
move_pthread_to_realtime_scheduling_class(pthread);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void thread_setup(pthread_t pthread) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void *
|
void *
|
||||||
@ -238,9 +245,7 @@ basic_test_setup(const struct testcase_t *testcase)
|
|||||||
evthread_flags |= EVTHREAD_PTHREAD_PRIO_INHERIT;
|
evthread_flags |= EVTHREAD_PTHREAD_PRIO_INHERIT;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
thread_setup(pthread_self());
|
||||||
move_pthread_to_realtime_scheduling_class(pthread_self());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (testcase->flags & TT_ENABLE_IOCP_FLAG)
|
if (testcase->flags & TT_ENABLE_IOCP_FLAG)
|
||||||
|
@ -27,22 +27,26 @@
|
|||||||
#ifndef REGRESS_THREAD_H_INCLUDED_
|
#ifndef REGRESS_THREAD_H_INCLUDED_
|
||||||
#define REGRESS_THREAD_H_INCLUDED_
|
#define REGRESS_THREAD_H_INCLUDED_
|
||||||
|
|
||||||
|
#include "regress.h"
|
||||||
|
|
||||||
#ifdef EVENT__HAVE_PTHREADS
|
#ifdef EVENT__HAVE_PTHREADS
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#define THREAD_T pthread_t
|
#define THREAD_T pthread_t
|
||||||
#define THREAD_FN void *
|
#define THREAD_FN void *
|
||||||
#define THREAD_RETURN() return (NULL)
|
#define THREAD_RETURN() return (NULL)
|
||||||
#define THREAD_START(threadvar, fn, arg) \
|
#define THREAD_START(threadvar, fn, arg) do { \
|
||||||
pthread_create(&(threadvar), NULL, fn, arg)
|
if (!pthread_create(&(threadvar), NULL, fn, arg)) \
|
||||||
|
thread_setup(threadvar); \
|
||||||
|
} while (0)
|
||||||
#define THREAD_JOIN(th) pthread_join(th, NULL)
|
#define THREAD_JOIN(th) pthread_join(th, NULL)
|
||||||
#else
|
#else
|
||||||
#define THREAD_T HANDLE
|
#define THREAD_T HANDLE
|
||||||
#define THREAD_FN unsigned __stdcall
|
#define THREAD_FN unsigned __stdcall
|
||||||
#define THREAD_RETURN() return (0)
|
#define THREAD_RETURN() return (0)
|
||||||
#define THREAD_START(threadvar, fn, arg) do { \
|
#define THREAD_START(threadvar, fn, arg) do { \
|
||||||
uintptr_t threadhandle = _beginthreadex(NULL,0,fn,(arg),0,NULL); \
|
uintptr_t threadhandle = _beginthreadex(NULL,0,fn,(arg),0,NULL); \
|
||||||
(threadvar) = (HANDLE) threadhandle; \
|
(threadvar) = (HANDLE) threadhandle; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define THREAD_JOIN(th) WaitForSingleObject(th, INFINITE)
|
#define THREAD_JOIN(th) WaitForSingleObject(th, INFINITE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user