comparison android/dw.cpp @ 2514:5f711e86a211

Android: Implement dw_main_sleep() and dw_main_iteration(). Using the sort of hacky exception handler method for now.... since Google doesn't seem to want us to do this in a clean way.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 07 May 2021 19:54:05 +0000
parents 0fa54c340902
children 211044d98e86
comparison
equal deleted inserted replaced
2513:0fa54c340902 2514:5f711e86a211
510 * Parameters: 510 * Parameters:
511 * milliseconds: Number of milliseconds to run the loop for. 511 * milliseconds: Number of milliseconds to run the loop for.
512 */ 512 */
513 void API dw_main_sleep(int milliseconds) 513 void API dw_main_sleep(int milliseconds)
514 { 514 {
515 JNIEnv *env;
516
517 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
518 {
519 // First get the class that contains the method you need to call
520 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
521 // Get the method that you want to call
522 jmethodID mainSleep = env->GetMethodID(clazz, "mainSleep",
523 "(I)V");
524 // Call the method on the object
525 env->CallVoidMethod(_dw_obj, mainSleep, milliseconds);
526 }
515 } 527 }
516 528
517 /* 529 /*
518 * Processes a single message iteration and returns. 530 * Processes a single message iteration and returns.
519 */ 531 */
520 void API dw_main_iteration(void) 532 void API dw_main_iteration(void)
521 { 533 {
534 /* If we sleep for 0 milliseconds... we will drop out
535 * of the loop at the first idle moment
536 */
537 dw_main_sleep(0);
522 } 538 }
523 539
524 /* 540 /*
525 * Cleanly terminates a DW session, should be signal handler safe. 541 * Cleanly terminates a DW session, should be signal handler safe.
526 * Parameters: 542 * Parameters: