Search code examples
kotlinquasar

Kotlin / Quasar Fiber Warning and Quitting


I'm studying Kotlin and Quasar and I'm trying to make "Boom" game. I think my code is nice, but when I execute, it gives is hogging the CPU or blocking a thread. warning or just quit, sometimes.

Am I did something wrong or not?

gist

Edit: full output


Solution

    1. Since you're spawning actors but not joining them from the main thread, the latter could exit before the former finish executing. Have a look at LocalActor.join.
    2. If you join both actors your program will hang when one fails because the other one will be awaiting for a message forever. Send an exit message to the other actor when failing or use a receive with a timeout and exit if a timeout occurs.
    3. The warning is perfectly normal because the Quasar runtime and the JVM are still "warming up" while executing your program, so for example in your trace Quasar is performing one-time thread-blocking operations while verifying your suspendable annotations. Here instead I got it while printing on stdout (which is a thread-blocking operation) presumably because the JVM didn't have optimized that code path yet (probably it was still running it in interpreted mode). You can disable that warning if you want with the co.paralleluniverse.fibers.detectRunawayFibers system property.