Reindent server/core/thread.c
This commit is contained in:
@ -23,8 +23,8 @@
|
|||||||
* @verbatim
|
* @verbatim
|
||||||
* Revision History
|
* Revision History
|
||||||
*
|
*
|
||||||
* Date Who Description
|
* Date Who Description
|
||||||
* 25/06/13 Mark Riddoch Initial implementation
|
* 25/06/13 Mark Riddoch Initial implementation
|
||||||
*
|
*
|
||||||
* @endverbatim
|
* @endverbatim
|
||||||
*/
|
*/
|
||||||
@ -33,46 +33,46 @@
|
|||||||
/**
|
/**
|
||||||
* Start a polling thread
|
* Start a polling thread
|
||||||
*
|
*
|
||||||
* @param entry The entry point to call
|
* @param entry The entry point to call
|
||||||
* @param arg The argument to pass the thread entry point
|
* @param arg The argument to pass the thread entry point
|
||||||
* @return The thread handle
|
* @return The thread handle
|
||||||
*/
|
*/
|
||||||
void *
|
void *
|
||||||
thread_start(void (*entry)(void *), void *arg)
|
thread_start(void (*entry)(void *), void *arg)
|
||||||
{
|
{
|
||||||
pthread_t thd;
|
pthread_t thd;
|
||||||
|
|
||||||
if (pthread_create(&thd, NULL, (void *(*)(void *))entry, arg) != 0)
|
if (pthread_create(&thd, NULL, (void *(*)(void *))entry, arg) != 0)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (void *)thd;
|
return (void *)thd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wait for a running threads to complete.
|
* Wait for a running threads to complete.
|
||||||
*
|
*
|
||||||
* @param thd The thread handle
|
* @param thd The thread handle
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
thread_wait(void *thd)
|
thread_wait(void *thd)
|
||||||
{
|
{
|
||||||
void *rval;
|
void *rval;
|
||||||
|
|
||||||
pthread_join((pthread_t)thd, &rval);
|
pthread_join((pthread_t)thd, &rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Put the thread to sleep for a number of milliseconds
|
* Put the thread to sleep for a number of milliseconds
|
||||||
*
|
*
|
||||||
* @param ms Number of milliseconds to sleep
|
* @param ms Number of milliseconds to sleep
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
thread_millisleep(int ms)
|
thread_millisleep(int ms)
|
||||||
{
|
{
|
||||||
struct timespec req;
|
struct timespec req;
|
||||||
|
|
||||||
req.tv_sec = ms / 1000;
|
req.tv_sec = ms / 1000;
|
||||||
req.tv_nsec = (ms % 1000) * 1000000;
|
req.tv_nsec = (ms % 1000) * 1000000;
|
||||||
nanosleep(&req, NULL);
|
nanosleep(&req, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file thread.h The gateway threading interface
|
* @file thread.h The gateway threading interface
|
||||||
*
|
*
|
||||||
* An encapsulation of the threading used by the gateway. This is designed to
|
* An encapsulation of the threading used by the gateway. This is designed to
|
||||||
* isolate the majority of the gateway code from th epthread library, enabling
|
* isolate the majority of the gateway code from th epthread library, enabling
|
||||||
@ -28,11 +28,11 @@
|
|||||||
* of changes.
|
* of changes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define THREAD pthread_t
|
#define THREAD pthread_t
|
||||||
#define THREAD_SHELF pthread_self
|
#define THREAD_SHELF pthread_self
|
||||||
|
|
||||||
extern void *thread_start(void (*entry)(void *), void *arg);
|
extern void *thread_start(void (*entry)(void *), void *arg);
|
||||||
extern void thread_wait(void *thd);
|
extern void thread_wait(void *thd);
|
||||||
extern void thread_millisleep(int ms);
|
extern void thread_millisleep(int ms);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user