且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Android和JNI实时时钟

更新时间:2023-02-26 17:17:33

计时器信号可能传递到了渲染器线程或主线程.在这种情况下,它将中断该线程(如果有)中正在进行的系统调用.这种情况可能会在运行时代码中触发一些断言.您可以玩SIGEV_THREAD_ID将信号定向到专用线程.但是请注意,此通知类型不适用于广泛使用.同样,一些实时信号可能会被仿生线程实现甚至ART静默使用.因此,很容易破坏某些东西.

Probably timer signal is delivered to renderer thread or main thread. In such case it interrupts system call that is in progress in that thread (if any). And this situation may trigger some assert in runtime code. You may play with SIGEV_THREAD_ID to direct signal to dedicated thread. But be aware that this notification type is not intended for widespread usage. Also some of real-time signals may be silently used by bionic threading implementation or even ART. So it is very easy to break something.

P.S.如果可能的话-您应该选择SIGEV_THREAD.由于您不应该考虑适当的信号编号等,因此它在Android上看起来更可靠.

P.S. if possible - you should prefer SIGEV_THREAD. It looks more reliable on Android since you shouldn't think about proper signal numbers etc.