diff --git a/include/maxscale/thread.h b/include/maxscale/thread.h deleted file mode 100644 index 99b7a94f1..000000000 --- a/include/maxscale/thread.h +++ /dev/null @@ -1,72 +0,0 @@ -#pragma once -/* - * Copyright (c) 2016 MariaDB Corporation Ab - * - * Use of this software is governed by the Business Source License included - * in the LICENSE.TXT file and at www.mariadb.com/bsl11. - * - * Change Date: 2022-01-01 - * - * On the date above, in accordance with the Business Source License, use - * of this software will be governed by version 2 or later of the General - * Public License. - */ - -/** - * @file thread.h The gateway threading interface - * - * An encapsulation of the threading used by the gateway. This is designed to - * isolate the majority of the gateway code from the pthread library, enabling - * the gateway to be ported to a different threading package with the minimum - * of changes. - */ - -#include - -MXS_BEGIN_DECLS - -/** - * Thread type and thread identifier function macros - */ -#include - -typedef pthread_t THREAD; - -/** - * Obtain a handle to the calling thread - * - * @return The thread handle of the calling thread. - */ -static inline THREAD thread_self() -{ - return pthread_self(); -} - -/** - * Start a secondary thread - * - * @param thd Pointer to the THREAD object - * @param entry The entry point to call - * @param arg The argument to pass the thread entry point - * @param stack_size The stack size of the thread. If 0, the default - * size will be used. - * - * @return The thread handle or NULL if an error occurred - */ -extern THREAD *thread_start(THREAD *thd, void (*entry)(void *), void *arg, size_t stack_size); - -/** - * Wait for a running thread to complete. - * - * @param thd The thread handle - */ -extern void thread_wait(THREAD thd); - -/** - * Put the calling thread to sleep for a number of milliseconds - * - * @param ms Number of milliseconds to sleep - */ -extern void thread_millisleep(int ms); - -MXS_END_DECLS diff --git a/server/core/CMakeLists.txt b/server/core/CMakeLists.txt index 44713b0a7..79f64e4a9 100644 --- a/server/core/CMakeLists.txt +++ b/server/core/CMakeLists.txt @@ -51,7 +51,6 @@ add_library(maxscale-common SHARED spinlock.cc ssl.cc statistics.cc - thread.cc users.cc utils.cc worker.cc diff --git a/server/core/thread.cc b/server/core/thread.cc deleted file mode 100644 index 9c56b673e..000000000 --- a/server/core/thread.cc +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2016 MariaDB Corporation Ab - * - * Use of this software is governed by the Business Source License included - * in the LICENSE.TXT file and at www.mariadb.com/bsl11. - * - * Change Date: 2022-01-01 - * - * On the date above, in accordance with the Business Source License, use - * of this software will be governed by version 2 or later of the General - * Public License. - */ - -#include -#include - -THREAD *thread_start(THREAD *thd, void (*entry)(void *), void *arg, size_t stack_size) -{ - THREAD* rv = NULL; - - pthread_attr_t attr; - int error = pthread_attr_init(&attr); - - if (error == 0) - { - if (stack_size != 0) - { - error = pthread_attr_setstacksize(&attr, stack_size); - } - - if (error == 0) - { - error = pthread_create(thd, &attr, (void *(*)(void *))entry, arg); - - if (error == 0) - { - rv = thd; - } - else - { - MXS_ERROR("Could not start thread: %s", mxs_strerror(error)); - } - } - else - { - MXS_ERROR("Could not set thread stack size to %lu: %s", stack_size, mxs_strerror(error)); - } - } - else - { - MXS_ERROR("Could not initialize thread attributes: %s", mxs_strerror(error)); - } - - return rv; -} - -void thread_wait(THREAD thd) -{ - void *rval; - - pthread_join((pthread_t)thd, &rval); -} - -void thread_millisleep(int ms) -{ - struct timespec req; - req.tv_sec = ms / 1000; - req.tv_nsec = (ms % 1000) * 1000000; - nanosleep(&req, NULL); -}