dropbox / djinni

A tool for generating cross-language type declarations and interface bindings.
Apache License 2.0
2.88k stars 488 forks source link

Provide a method to run functions on JVM thread #398

Closed jonmcclung closed 5 years ago

jonmcclung commented 5 years ago

This is an attempt to provide a way for C++-created threads to call into Java without risking a memory leak, as requested in #176 . The basic idea is this:

There are two functions because I'm not skilled enough with lambdas to make one function that will accept any kind of lambda.

mjmacleod commented 5 years ago

I've tested this and confirm it works my side.

However I don't personally like the extra code clutter to use this, nor the overhead of constantly attaching/detaching. I've implemented the code suggestions in #372 as an alternative pull request #405 that could possibly be used instead of this though I guess there is no reason they could not both co-exist also.

mjmacleod commented 5 years ago

Just a note that #405 has been merged now, I'm not sure if there is a good reason to have more than one way to do this or not.

shahzadlone commented 5 years ago

Just a note that #405 has been merged now, I'm not sure if there is a good reason to have more than one way to do this or not.

That's fair enough. I just pointed out because I have seen some pretty tedious bugs introduced because of the missing braces after an if.

artwyman commented 5 years ago

405 provided an alternative option to this. This repo isn't going to be adding any new features so I'm putting this PR on hold.