Highlander is a simple pyamsoft Android library which helped ensure that only a single instance of a coroutine was running at any given time.
It was one of the earliest pyamsoft libraries that dealt with Coroutines, and it was over-engineered due to a misunderstanding of what coroutines were. A coroutine can mimic Highlander behavior, by simply assigning the launched Job to a variable and canceling the variable before attempting a new Job launch.
Simple, stupid, and no maintaining required.
Worried about race conditions? You are either in a suspending function already and you can use a Mutex to lock and ensure assignments, or you are not in a suspending function and thus can either safely cancel-and-assign a new job (like on the Main Thread), or you can launch a simple coroutine that then allows you to access the Mutex and launch your real coroutine after you have ensured it was cancelled. Easy peasy! Go forth, and adhere to best practices!
Stay tuned!
========================
Follow pyamsoft around the Web for updates and announcements about the newest applications!
Like what I do?
Send me an email at: pyam.soft@gmail.com
Or find me online at: https://pyamsoft.blogspot.com
Follow my Facebook Page
Check out my code on GitHub
=========================
========================
Follow pyamsoft around the Web for updates and announcements about the newest applications!
Like what I do?
Send me an email at: pyam.soft@gmail.com
Or find me online at: https://pyamsoft.blogspot.com
Follow my Facebook Page
Check out my code on GitHub
=========================