Reindent server/core/thread.c

This commit is contained in:
Johan Wikman 2015-11-30 20:17:43 +02:00
parent a95be21266
commit 8bbc3e8086
2 changed files with 25 additions and 25 deletions

View File

@ -23,8 +23,8 @@
* @verbatim
* Revision History
*
* Date Who Description
* 25/06/13 Mark Riddoch Initial implementation
* Date Who Description
* 25/06/13 Mark Riddoch Initial implementation
*
* @endverbatim
*/
@ -33,46 +33,46 @@
/**
* Start a polling thread
*
* @param entry The entry point to call
* @param arg The argument to pass the thread entry point
* @return The thread handle
* @param entry The entry point to call
* @param arg The argument to pass the thread entry point
* @return The thread handle
*/
void *
thread_start(void (*entry)(void *), void *arg)
{
pthread_t thd;
pthread_t thd;
if (pthread_create(&thd, NULL, (void *(*)(void *))entry, arg) != 0)
{
return NULL;
}
return (void *)thd;
if (pthread_create(&thd, NULL, (void *(*)(void *))entry, arg) != 0)
{
return NULL;
}
return (void *)thd;
}
/**
* Wait for a running threads to complete.
*
* @param thd The thread handle
* @param thd The thread handle
*/
void
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
*
* @param ms Number of milliseconds to sleep
* @param ms Number of milliseconds to sleep
*/
void
thread_millisleep(int ms)
{
struct timespec req;
struct timespec req;
req.tv_sec = ms / 1000;
req.tv_nsec = (ms % 1000) * 1000000;
nanosleep(&req, NULL);
req.tv_sec = ms / 1000;
req.tv_nsec = (ms % 1000) * 1000000;
nanosleep(&req, NULL);
}

View File

@ -20,7 +20,7 @@
#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
* isolate the majority of the gateway code from th epthread library, enabling
@ -28,11 +28,11 @@
* of changes.
*/
#define THREAD pthread_t
#define THREAD_SHELF pthread_self
#define THREAD pthread_t
#define THREAD_SHELF pthread_self
extern void *thread_start(void (*entry)(void *), void *arg);
extern void thread_wait(void *thd);
extern void thread_millisleep(int ms);
extern void *thread_start(void (*entry)(void *), void *arg);
extern void thread_wait(void *thd);
extern void thread_millisleep(int ms);
#endif