mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 08:11:33 +11:00
initialise to the no logger iff no other logger has been loaded
This commit is contained in:
parent
3430668bdd
commit
987928a9a8
|
@ -1,7 +1,7 @@
|
|||
mod log;
|
||||
mod vfile;
|
||||
|
||||
use std::ptr::NonNull;
|
||||
use std::{ptr::NonNull, sync::atomic::{AtomicBool, Ordering}};
|
||||
|
||||
pub use log::{Logger, LogLevel};
|
||||
pub use vfile::{file::FileBacked, memory::MemoryBacked, shared::Shared, MapFlag, VFile};
|
||||
|
@ -27,13 +27,18 @@ macro_rules! call_on_core {
|
|||
};
|
||||
}
|
||||
|
||||
static GLOBAL_LOGGER_HAS_BEEN_INITIALISED: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
pub fn set_global_default_logger(logger: &'static Logger) {
|
||||
GLOBAL_LOGGER_HAS_BEEN_INITIALISED.store(true, Ordering::SeqCst);
|
||||
unsafe { mgba_sys::mLogSetDefaultLogger(logger.to_mgba()) }
|
||||
}
|
||||
|
||||
impl MCore {
|
||||
pub fn new() -> Option<Self> {
|
||||
if !GLOBAL_LOGGER_HAS_BEEN_INITIALISED.load(Ordering::SeqCst) {
|
||||
set_global_default_logger(&log::NO_LOGGER);
|
||||
}
|
||||
|
||||
let core = unsafe { mgba_sys::GBACoreCreate() };
|
||||
let core = NonNull::new(core)?;
|
||||
|
|
Loading…
Reference in a new issue