057fe1910d
Including thread.h brings a massive array of things with it from the kernel thread arch headers, team and thread definitions, hash tables, linked lists, Referenceable, etc. that the vast majority of AutoLock.h consumers neither want nor need. So, put these in a separate header, and adjust all consumers of these lockers to include the new file. This change exposes the fact that a lot of files were inadvertently making use of headers included indirectly through thread.h. Those will be fixed in the next commit.
44 lines
793 B
C++
44 lines
793 B
C++
/*
|
|
* Copyright 2021, Haiku, Inc. All rights reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef KERNEL_UTIL_THREAD_AUTO_LOCKER_H
|
|
#define KERNEL_UTIL_THREAD_AUTO_LOCKER_H
|
|
|
|
|
|
#include <shared/AutoLocker.h>
|
|
|
|
#include <thread.h>
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
class ThreadCPUPinLocking {
|
|
public:
|
|
inline bool Lock(Thread* thread)
|
|
{
|
|
thread_pin_to_current_cpu(thread);
|
|
return true;
|
|
}
|
|
|
|
inline void Unlock(Thread* thread)
|
|
{
|
|
thread_unpin_from_current_cpu(thread);
|
|
}
|
|
};
|
|
|
|
typedef AutoLocker<Thread, ThreadCPUPinLocking> ThreadCPUPinner;
|
|
typedef AutoLocker<Team> TeamLocker;
|
|
typedef AutoLocker<Thread> ThreadLocker;
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
using BPrivate::ThreadCPUPinner;
|
|
using BPrivate::TeamLocker;
|
|
using BPrivate::ThreadLocker;
|
|
|
|
|
|
#endif // KERNEL_UTIL_THREAD_AUTO_LOCKER_H
|