kernel: Break thread-related AutoLockers into a separate header.

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.
This commit is contained in:
Augustin Cavalier
2021-09-01 13:08:49 -04:00
parent a0c6f022c4
commit 057fe1910d
25 changed files with 66 additions and 25 deletions
@@ -0,0 +1,43 @@
/*
* 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