Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Story thread-safe behind feature flag #2

Open
IFcoltransG opened this issue Oct 21, 2023 · 5 comments
Open

Story thread-safe behind feature flag #2

IFcoltransG opened this issue Oct 21, 2023 · 5 comments

Comments

@IFcoltransG
Copy link
Contributor

There's some work going on to use Blade Ink in a Bevy game engine plugin for Ink, but Bevy strongly prefers Send types so it can parallelise. It would be valuable if Story were Send.

For example, there could be a crate feature flag that replaces a type Ref<T> = Rc<T> with type Ref<T> = Arc<T> and similar for Mutex instead of RefCell. That way users who only need single-threaded can avoid the slight overhead of Arc over Rc.

@LeCalicot
Copy link

@bladecoder would you need some help to work on that feature?
On our side, we are blocked for the bevy integration by this issue, so we may as well help if we can :)

@bladecoder
Copy link
Owner

bladecoder commented Oct 23, 2023

@IFcoltransG I like the way you propose to support threadsafe through a feature. I started to implement it in this branch and I realized it is not as easy as it seems.

I used RwLock as substitute of RefCell but the methods are different, so we will need to implement these methods and use them in all the code. I have implemented the brcell_borrow method in the threadsafe.rs file as a proof of concept and it works (see use in native_function_call.rs).

@LeCalicot Help is always welcome ! I let you complete this feature if you want. Just create a PR when you are finish and I will review it before merging.

Thanks

@LeCalicot
Copy link

To be honest, it might take me a long time, I'm that good with rust yet.

@jaminhaber
Copy link

You can use bladeink in a bevy game as a NonSend resource and emit events whenever something changes in the story

@IFcoltransG
Copy link
Contributor Author

@jaminhaber That's what I'm doing for a current project, but lack of Send does prevent making a story into a component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants