summaryrefslogtreecommitdiff
path: root/ecs/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ecs/src/lib.rs')
-rw-r--r--ecs/src/lib.rs29
1 files changed, 6 insertions, 23 deletions
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs
index 5273b67..1c4e44f 100644
--- a/ecs/src/lib.rs
+++ b/ecs/src/lib.rs
@@ -7,6 +7,7 @@ use std::marker::PhantomData;
use std::mem::ManuallyDrop;
use std::ops::RangeBounds;
use std::slice::Iter as SliceIter;
+use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Weak};
use std::vec::Drain;
@@ -26,7 +27,6 @@ use crate::type_name::TypeName;
pub mod actions;
pub mod component;
pub mod event;
-pub mod flags;
pub mod lock;
pub mod system;
pub mod tuple;
@@ -53,6 +53,7 @@ pub struct World
{
systems: Vec<TypeErasedSystem>,
data: WorldData,
+ stop: AtomicBool,
}
impl World
@@ -160,6 +161,9 @@ impl World
.collect(),
});
}
+ Action::Stop => {
+ self.stop.store(true, Ordering::Relaxed);
+ }
}
}
}
@@ -179,13 +183,7 @@ impl World
self.perform_queued_actions();
- let flags = self
- .data
- .flags
- .read_nonblock()
- .expect("Failed to aquire lock to flags");
-
- if flags.stop {
+ if self.stop.load(Ordering::Relaxed) {
break;
}
}
@@ -209,26 +207,11 @@ impl World
}
#[derive(Debug, Default)]
-struct WorldFlags
-{
- stop: bool,
-}
-
-impl TypeName for WorldFlags
-{
- fn type_name(&self) -> &'static str
- {
- type_name::<Self>()
- }
-}
-
-#[derive(Debug, Default)]
pub struct WorldData
{
events: HashMap<EventId, Vec<usize>>,
component_storage: Arc<Lock<ComponentStorage>>,
action_queue: Lock<ActionQueue>,
- flags: Lock<WorldFlags>,
}
#[derive(Debug, Default)]