Skip to content

Detach current thread only at its exit #20

Description

@MatteoArella

Actually we are calling AttachCurrentThread and DetachCurrentThread inside the logger_handler function (https://github.com/roc-project/roc-java/blob/master/roc_jni/src/main/cpp/logger.cpp);

As it has been discussed at #18 this can slow down performances.

A more efficient solution would involve detaching thread just before its exit, as it's described at https://developer.android.com/training/articles/perf-jni#threads:

you can use pthread_key_create() to define a destructor function that will be called before the thread exits, and call DetachCurrentThread() from there. (Use that key with pthread_setspecific() to store the JNIEnv in thread-local-storage).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions