replace GlobalScope with CoroutineScope in CacheController

This commit is contained in:
Jannik 2021-10-31 22:20:14 +01:00
parent dc6c41578a
commit a212539366
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
1 changed files with 3 additions and 3 deletions

View File

@ -157,7 +157,7 @@ class CacheController {
* this function updates the courseList
* during the update process the old data will be returned for an API request
*/
private fun asyncUpdateCourseList() = GlobalScope.launch {
private fun asyncUpdateCourseList() = CoroutineScope(Dispatchers.IO).launch {
CourseListParser().getCourseLinks(StartupController.courseListURL)?.let {
courseList = CoursesList(CoursesMeta(System.currentTimeMillis() / 1000, it.size), it.toSortedMap())
}
@ -173,7 +173,7 @@ class CacheController {
* this function updates the mensa menu list
* during the update process the old data will be returned for an API request
*/
private fun asyncUpdateMensa() = GlobalScope.launch {
private fun asyncUpdateMensa() = CoroutineScope(Dispatchers.IO).launch {
val mensaCurrentWeek = MensaParser().getMensaMenu(StartupController.mensaMenuURL)
val mensaNextWeek = MensaParser().getMensaMenu(MensaParser().getMenuLinkNextWeek(StartupController.mensaMenuURL))
@ -190,7 +190,7 @@ class CacheController {
* during the update process the old data will be returned for an API request
* a FixedThreadPool is used to make parallel requests for faster updates
*/
private fun asyncUpdateTimetables() = GlobalScope.launch {
private fun asyncUpdateTimetables() = CoroutineScope(Dispatchers.IO).launch {
logger.info("Updating ${timetableList.size} timetables ...")
// create a new ThreadPool with 5 threads