MXS-1360 Make it possible to specify thread stack size

It is now possible to specify the thread stack size to be used,
when a new thread is created. This will subsequently be used
for allowing the stack size to be specified for worker threads.
This commit is contained in:
Johan Wikman
2017-08-14 14:17:17 +03:00
parent bdb0f7d8d7
commit e9b2a560b8
13 changed files with 87 additions and 54 deletions

View File

@ -29,11 +29,44 @@ MXS_BEGIN_DECLS
* Thread type and thread identifier function macros
*/
#include <pthread.h>
#define THREAD pthread_t
#define thread_self() pthread_self()
extern THREAD *thread_start(THREAD *thd, void (*entry)(void *), void *arg);
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