Comments (4)
I don't know why you have something !Send + !Sync
where the bunny demo doesn't. Maybe wgpu
changed, the demo uses wgpu
0.15 which is not the latest version.
Regardless of why, if you have a !Send
/!Sync
type you can still store it in World
, you'll need to add the thread_local
cargo feature to shipyard.
Then use World::add_unique_non_send_sync
instead of World::add_unique
.
Finally when you borrow/define a system you'll have to use NonSendSync<UniqueView<Render>>
instead of UniqueView<Render>
.
Note: adding thread_local
feature will make World: !Send
from shipyard.
Thank you, @leudz! Your explanation worked perfectly! I was confused by combination of factors that wgpu removed Send Sync from version 0.16 and that it is not add_unique
which will act differently but dedicated method add_unique_non_send_sync
. So what I have now is this:
#[cfg(feature = "web")]
pub fn add_unique<T: Unique>(&mut self, component: T) -> &mut Self {
self.world.add_unique_non_send_sync(component);
self
}
#[cfg(not(feature = "web"))]
pub fn add_unique<T: Send + Sync + Unique>(&mut self, component: T) -> &mut Self {
self.world.add_unique(component);
self
}
from shipyard.
@leudz are there other limitations? I am using workloads and when I add system with |mut render: NonSendSync<UniqueView<Render>>| {
it will panic. Even if my Render is empty struct without !Sync properties. And works fine if I do it this way ``|mut render: UniqueView`. It panics not when add into workload but when run workload of multiple systems. Can you actually mix sync and non sync systems inside one workload?
from shipyard.
@leudz thank you for your support. I did not find the solution to this problem but closing the ticket because of migration to another ECS.
from shipyard.
Related Issues (20)
- How to query a entity by a component value, not component type? HOT 1
- Is there any way to add multiple tracking options to component except #[track(All)]? HOT 4
- Workload scheduling re-evaluation
- How to get+modify a component on one entity? HOT 5
- How to make certain systems always run first? HOT 8
- Help me some lifetime issue.. HOT 3
- Can I run some systems in parallel if UniqueViewMut is thread-safe? HOT 2
- Create a way to easily derive the Label trait HOT 1
- AtomicU64 is not available on 32-bit platforms HOT 6
- Component iteration without modification tracking HOT 2
- Tracking compiles but panics on run HOT 6
- Potential memory leak HOT 2
- Question about EntityId management HOT 3
- Can I get all of the components of the entity? HOT 2
- Better error message for boxed traits in components HOT 1
- Tracking flag error HOT 1
- How to use generic ViewMut with_id? HOT 1
- Potentially useful pattern for working with complex state machines with shipyard ECS HOT 1
- How does the current field in ViewMut struct change? What's the flow?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shipyard.