chore: move event loop recreation check into backends themselves
This commit is contained in:
parent
5f2c7350e9
commit
8ad016362a
12 changed files with 64 additions and 25 deletions
|
|
@ -6,7 +6,7 @@ use std::cell::Cell;
|
|||
use std::ffi::c_void;
|
||||
use std::os::windows::io::{AsRawHandle as _, FromRawHandle as _, OwnedHandle, RawHandle};
|
||||
use std::rc::Rc;
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
use std::sync::atomic::{AtomicBool, AtomicU32, Ordering};
|
||||
use std::sync::{Arc, LazyLock, Mutex, MutexGuard};
|
||||
use std::time::{Duration, Instant};
|
||||
use std::{fmt, mem, panic, ptr};
|
||||
|
|
@ -195,6 +195,12 @@ impl EventLoop {
|
|||
pub fn new(
|
||||
attributes: &mut PlatformSpecificEventLoopAttributes,
|
||||
) -> Result<Self, EventLoopError> {
|
||||
static EVENT_LOOP_CREATED: AtomicBool = AtomicBool::new(false);
|
||||
if EVENT_LOOP_CREATED.swap(true, Ordering::Relaxed) {
|
||||
// For better cross-platformness.
|
||||
return Err(EventLoopError::RecreationAttempt);
|
||||
}
|
||||
|
||||
let thread_id = unsafe { GetCurrentThreadId() };
|
||||
|
||||
if !attributes.any_thread && thread_id != main_thread_id() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue