https://kotlinlang.org logo
#coroutines
Title
# coroutines
t

Tristan Caron

03/21/2018, 3:22 PM
Hello, Do you know how I can prevent a job to be run if one is already running?
Copy code
// From Ktor
    get("/longtask") {
        call.respondText("OK")

        runLongTask(settings) // Returns a Job
    }
What I would like is, when
/longtask
is called for the first time, call the function
runLongTask
, but if it's called a second time, and
runLongTask
from the first call is not finished yet, to run it again. Not at all.
e

elizarov

03/21/2018, 7:16 PM
So do you want to run it the second time or not?
t

Tristan Caron

03/22/2018, 7:04 AM
Not :)
3 Views