[concurrency-interest] JNI signaling back to a thread/concurrent structure?
aph at redhat.com
Tue Jul 14 05:28:12 EDT 2015
On 14/07/15 09:43, Andrew Lentvorski wrote:
> However, if something is going wrong and the circular audio buffer
> is about to empty, I would like to do something that would wake up
> the Java thread or at least queue it on a relatively soon timeslice.
> Maybe it can recover and maybe it can't, but without the ability to
> signal that, the thread is going to stay asleep and the audio buffer
> will drain.
> Now, I can just wake the thread up every so many milliseconds, but
> that's kind of wasteful of power, CPU, etc. as the majority of the
> time the thread is just going to wake up to see that the buffer is
> fine, realize it has no work and go back to sleep.
Ah yes, priority inversion, or something similar. If you know how to
wake your Java task then you can use the invocation API from JNI code
to call some Java code which will wake the Java thread. I'm guessing
you must know that, but want to do something different.
More information about the Concurrency-interest