All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fireflysource.net.tcp.aio.AioTcpCoroutineDispatcher.kt Maven / Gradle / Ivy

There is a newer version: 5.0.2
Show newest version
package com.fireflysource.net.tcp.aio

import com.fireflysource.net.tcp.TcpCoroutineDispatcher
import kotlinx.coroutines.*

class AioTcpCoroutineDispatcher(
    id: Int,
    private val dispatcher: CoroutineDispatcher,
    private val supervisor: CompletableJob = SupervisorJob(),
    private val scope: CoroutineScope = CoroutineScope(dispatcher + supervisor + CoroutineName("TcpConnection#$id"))
) : TcpCoroutineDispatcher {
    
    override fun getCoroutineDispatcher(): CoroutineDispatcher = dispatcher

    override fun getSupervisorJob(): CompletableJob = supervisor

    override fun getCoroutineScope(): CoroutineScope = scope

    override fun execute(runnable: Runnable) {
        scope.launch { runnable.run() }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy