mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:08: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
|
@ -24,6 +24,7 @@
|
|||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/Singleton.h>
|
||||
#include <Kernel/Console.h>
|
||||
#include <Kernel/IO.h>
|
||||
#include <Kernel/kstdio.h>
|
||||
|
@ -32,24 +33,27 @@
|
|||
// Bytes output to 0xE9 end up on the Bochs console. It's very handy.
|
||||
#define CONSOLE_OUT_TO_E9
|
||||
|
||||
static Console* s_the;
|
||||
static AK::Singleton<Console> s_the;
|
||||
static Kernel::SpinLock g_console_lock;
|
||||
|
||||
void Console::initialize()
|
||||
{
|
||||
s_the.ensure_instance();
|
||||
}
|
||||
|
||||
Console& Console::the()
|
||||
{
|
||||
ASSERT(s_the);
|
||||
return *s_the;
|
||||
}
|
||||
|
||||
bool Console::is_initialized()
|
||||
{
|
||||
return s_the != nullptr;
|
||||
return s_the.is_initialized();
|
||||
}
|
||||
|
||||
Console::Console()
|
||||
: CharacterDevice(5, 1)
|
||||
{
|
||||
s_the = this;
|
||||
}
|
||||
|
||||
Console::~Console()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue