I was wondering is there any way to limit number of parallel workers of only one type.
So I have UploadWorker, witch backups single file. I want to be able to limit how much uploads go in parallel.
And with
val configuration = Configuration.Builder()
.setExecutor(Executors.newFixedThreadPool(2))
.build()
WorkManager.initialize(context, configuration)
it is all good for upload part. I can just dump work requests as I collect new items for upload.
But I have other Workers, and I do not want for UploadWorker work requests to finish, but I want those to run as soon as possible.
How can I manage that?
Thanks
I have figured it out.
If I use regular worker for UploadWorker, and CoroutineWorker for others, then UploadWorker will run on configured Executor, while CoroutineWorker runs on default Dispatcher or any other that I want.