Small utility Kotlin library, PriorityDispatcher, that prioritise tasks within coroutines based on a priority queue.
To integrate PriorityDispatcher library into your projects, follow these simple steps:
- Update your settings.gradle file with the following dependency.
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // this one
}
}
- Update your module level build.gradle file with the following dependency.
dependencies {
implementation 'com.github.khushpanchal:PriorityDispatcher:1.0.1'
}
- Low Level Priority Task
CoroutineScope(PriorityDispatcher.low()).launch {
// Task with low priority
}
- Medium Level Priority Task
CoroutineScope(PriorityDispatcher.medium()).launch {
// Task with medium priority
}
- High Level Priority Task
CoroutineScope(PriorityDispatcher.high()).launch {
// Task with high priority
}
- Immediate Level Priority Task
CoroutineScope(PriorityDispatcher.immediate()).launch {
// Task with immediate priority - Runs irrespective of current workload
}
Blog: Check out the blog for more guided and technical details: Medium Blog
If this project helps you, show love ❤️ by putting a ⭐ on this project ✌️
Feel free to provide feedback, report an issue, or contribute to PriorityDispatcher. Head over to GitHub repository, create an issue or find the pending issue. All pull requests are welcome 😄
Copyright (C) 2024 Khush Panchal
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.