8000 Add static bound for add_fd_with_callback · Issue #504 · rust-mobile/ndk · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Add static bound for add_fd_with_callback #504
Open
@yyy33

Description

@yyy33

Since the callback is leaking into memory, should we add a 'static constraint to it to make sure it's always valid, otherwise a JNIEnv <'local> is captured here, and it compiles. But the JNIEnv is only valid in the scope of the native method on_create

//native jni method
pub fn on_create(mut env: JNIEnv, jactivity: JObject) {
    ThreadLooper::for_thread()
        .unwrap()
        .add_fd_with_callback(fd, FdEvent::INPUT, move || {
            env.call_method(obj, name, sig, args);
        })?;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0