mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:48:10 +00:00
Kernel: Switch singletons to use new Singleton class
MemoryManager cannot use the Singleton class because MemoryManager::initialize is called before the global constructors are run. That caused the Singleton to be re-initialized, causing it to create another MemoryManager instance. Fixes #3226
This commit is contained in:
parent
ba6e4fb77f
commit
d89582880e
46 changed files with 221 additions and 170 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Singleton.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Arch/i386/CPU.h>
|
||||
|
@ -335,11 +336,15 @@ void KeyboardDevice::handle_irq(const RegisterState&)
|
|||
}
|
||||
}
|
||||
|
||||
static KeyboardDevice* s_the;
|
||||
static AK::Singleton<KeyboardDevice> s_the;
|
||||
|
||||
void KeyboardDevice::initialize()
|
||||
{
|
||||
s_the.ensure_instance();
|
||||
}
|
||||
|
||||
KeyboardDevice& KeyboardDevice::the()
|
||||
{
|
||||
ASSERT(s_the);
|
||||
return *s_the;
|
||||
}
|
||||
|
||||
|
@ -347,8 +352,6 @@ KeyboardDevice::KeyboardDevice()
|
|||
: IRQHandler(IRQ_KEYBOARD)
|
||||
, CharacterDevice(85, 1)
|
||||
{
|
||||
s_the = this;
|
||||
|
||||
// Empty the buffer of any pending data.
|
||||
// I don't care what you've been pressing until now!
|
||||
while (IO::in8(I8042_STATUS) & I8042_BUFFER_FULL)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue