Files
compute-runtime/shared/source/os_interface/linux/os_thread_linux.cpp
Mateusz Jablonski 7ac41615cd fix: create thread with function pointer
don't create async thread in neo shared tests

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
2024-08-21 18:02:37 +02:00

32 lines
676 B
C++

/*
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/os_thread_linux.h"
#include <sched.h>
namespace NEO {
ThreadLinux::ThreadLinux(pthread_t threadId) : threadId(threadId){};
decltype(&Thread::create) Thread::createFunc = Thread::create;
std::unique_ptr<Thread> Thread::create(void *(*func)(void *), void *arg) {
pthread_t threadId;
pthread_create(&threadId, nullptr, func, arg);
return std::unique_ptr<Thread>(new ThreadLinux(threadId));
}
void ThreadLinux::join() {
pthread_join(threadId, nullptr);
}
void ThreadLinux::yield() {
sched_yield();
}
} // namespace NEO