cOMS/thread/Thread.h

39 lines
805 B
C

/**
* Jingga
*
* @copyright Jingga
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
#ifndef TOS_THREADS_THREAD_H
#define TOS_THREADS_THREAD_H
#include <stdio.h>
#include "../stdlib/Types.h"
#include "Atomic.h"
#if _WIN32
#include "../platform/win32/threading/Thread.h"
#elif __linux__
#include "../platform/linux/threading/Thread.h"
#endif
#include "ThreadJob.h"
#include "ThreadPool.h"
void thread_create(Worker* worker, ThreadJobFunc routine, void* arg)
{
// @todo test to remove {}
LOG_LEVEL_2("Thread started", {});
pthread_create(&worker->thread, NULL, routine, arg);
}
void thread_stop(Worker* worker)
{
atomic_set_acquire(&worker->state, 0);
pthread_join(worker->thread, NULL);
LOG_LEVEL_2("Thread ended", {});
}
#endif