1/*
2 * Copyright 2021, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef KERNEL_UTIL_THREAD_AUTO_LOCKER_H
6#define KERNEL_UTIL_THREAD_AUTO_LOCKER_H
7
8
9#include <shared/AutoLocker.h>
10
11#include <thread.h>
12
13
14namespace BPrivate {
15
16
17class ThreadCPUPinLocking {
18public:
19	inline bool Lock(Thread* thread)
20	{
21		thread_pin_to_current_cpu(thread);
22		return true;
23	}
24
25	inline void Unlock(Thread* thread)
26	{
27		thread_unpin_from_current_cpu(thread);
28	}
29};
30
31typedef AutoLocker<Thread, ThreadCPUPinLocking> ThreadCPUPinner;
32typedef AutoLocker<Team> TeamLocker;
33typedef AutoLocker<Thread> ThreadLocker;
34
35
36}	// namespace BPrivate
37
38using BPrivate::ThreadCPUPinner;
39using BPrivate::TeamLocker;
40using BPrivate::ThreadLocker;
41
42
43#endif	// KERNEL_UTIL_THREAD_AUTO_LOCKER_H
44