mirror of
https://github.com/mmueller41/mxtasking.git
synced 2026-01-21 12:42:57 +01:00
Removed unnecessary class mx::system::thread.
This commit is contained in:
@@ -1,39 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <chrono>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <iostream>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
namespace mx::system {
|
|
||||||
/**
|
|
||||||
* Encapsulates methods for thread access.
|
|
||||||
*/
|
|
||||||
/* Deprecated for Genode */
|
|
||||||
/* Done: mx::system::thread : Replace POSIX-style thread pinning with Genode thread affinities */
|
|
||||||
|
|
||||||
class thread
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Pins a thread to a given core.
|
|
||||||
*
|
|
||||||
* @param thread Thread to pin.
|
|
||||||
* @param core_id Core where the thread should be pinned.
|
|
||||||
* @return True, when pinning was successful.
|
|
||||||
*/
|
|
||||||
static bool pin(std::thread &thread, const std::uint16_t core_id)
|
|
||||||
{
|
|
||||||
cpu_set_t cpu_set;
|
|
||||||
CPU_ZERO(&cpu_set);
|
|
||||||
CPU_SET(core_id, &cpu_set);
|
|
||||||
|
|
||||||
if (pthread_setaffinity_np(thread.native_handle(), sizeof(cpu_set_t), &cpu_set) != 0)
|
|
||||||
{
|
|
||||||
std::cerr << "Can not pin thread!" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} // namespace mx::system
|
|
||||||
Reference in New Issue
Block a user