This may be a basic question as I’m brand new to c...
# coroutines
j
This may be a basic question as I’m brand new to coroutines, but my Google fu is failing me at the moment. I am starting a coroutine to make a web service call. I would like to make it so that only one instance of this coroutine is running at a given time. Is saving off the job that is returned and checking it’s status before kicking off a new job the correct way to do this or is there a better way?
z
Do you care about how many coroutines are running or how many calls are in flight concurrently? If the latter, you could use a mutex or a semaphore
1
j
I care about how many calls are in flight concurrently, but I don’t want to queue up multiple calls and have them run upon completion of previous calls though. I only want to kick off a new call if there isn’t a call in flight currently.
The use case is preventing an accidental double tap from the user from making the request twice. I’m disabling the UI element to prevent those after the first click, but I’ve seen cases in the past where they can still slip through.
r