Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

Send feature flag #411

Open
lewisclark opened this issue Jun 4, 2024 · 2 comments
Open

Send feature flag #411

lewisclark opened this issue Jun 4, 2024 · 2 comments
Labels
question Further information is requested

Comments

@lewisclark
Copy link

Is there anything I need to be careful of when using the send feature flag? It being locked behind a feature flag makes me wary that it has some side effects, as otherwise Send could be implemented by default?

@khvzak
Copy link
Member

khvzak commented Jun 4, 2024

It adds Send requirements to Rust functions and userdata objects, which is not always desirable. Also don't be confused with Sync.

PS. Next mlua version will have send feature flag replaced with sync to allow easy integration with multithreading code.

@khvzak khvzak added the question Further information is requested label Jun 4, 2024
@cppcoffee
Copy link

cppcoffee commented Jun 7, 2024

Added the send and async features to Cargo.toml, then placed the Lua object into the BoxFeature. Compiler prompted an error:

*mut c_void cannot be shared between threads safely.

After reviewing the code, should we modify *mut c_void to AtomicPtr?

like:

pub struct LuaInner {
    state: AtomicPtr<ffi::lua_State>,
    // replace main_state: *mut ffi::lua_State,
    main_state: AtomicPtr<ffi::lua_State>,
    extra: Arc<UnsafeCell<ExtraData>>,
}

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

No branches or pull requests

3 participants