mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-27 12:05:22 +00:00
refactor: use a shared timer in JobQueue.kt
This commit is contained in:
parent
924f58f816
commit
3b2589b835
@ -19,6 +19,7 @@ class JobQueue : JobDelegate {
|
||||
private val dispatcher = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
|
||||
private val scope = GlobalScope + SupervisorJob()
|
||||
private val queue = Channel<Job>(UNLIMITED)
|
||||
val timer = Timer()
|
||||
|
||||
init {
|
||||
// process jobs
|
||||
@ -77,7 +78,7 @@ class JobQueue : JobDelegate {
|
||||
} else {
|
||||
val retryInterval = getRetryInterval(job)
|
||||
Log.i("Jobs", "${job::class.simpleName} failed; scheduling retry (failure count is ${job.failureCount}).")
|
||||
Timer().schedule(delay = retryInterval) {
|
||||
timer.schedule(delay = retryInterval) {
|
||||
Log.i("Jobs", "Retrying ${job::class.simpleName}.")
|
||||
queue.offer(job)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user