mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:58:11 +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
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Memory.h>
|
||||
#include <AK/Singleton.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <Kernel/Devices/SB16.h>
|
||||
#include <Kernel/Thread.h>
|
||||
|
@ -76,13 +77,12 @@ void SB16::set_sample_rate(uint16_t hz)
|
|||
dsp_write((u8)hz);
|
||||
}
|
||||
|
||||
static SB16* s_the;
|
||||
static AK::Singleton<SB16> s_the;
|
||||
|
||||
SB16::SB16()
|
||||
: IRQHandler(SB16_DEFAULT_IRQ)
|
||||
, CharacterDevice(42, 42) // ### ?
|
||||
{
|
||||
s_the = this;
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,11 @@ SB16::~SB16()
|
|||
{
|
||||
}
|
||||
|
||||
void SB16::create()
|
||||
{
|
||||
s_the.ensure_instance();
|
||||
}
|
||||
|
||||
SB16& SB16::the()
|
||||
{
|
||||
return *s_the;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue