This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DatabaseWorkerPool : CoroutineScope { | |
private const val MAX_TASKS = 4 | |
internal class Task<R>(owner: Job, val request: suspend () -> R) { | |
val response = CompletableDeferred<R>(owner) | |
} | |
@Suppress("MemberVisibilityCanBePrivate") | |
internal val tasks = Channel<Task<*>>(Channel.UNLIMITED) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.CoroutineDispatcher | |
import kotlinx.coroutines.CoroutineScope | |
import kotlinx.coroutines.Dispatchers | |
import kotlinx.coroutines.asCoroutineDispatcher | |
import kotlinx.coroutines.joinAll | |
import kotlinx.coroutines.launch | |
import kotlinx.coroutines.runBlocking | |
import kotlinx.coroutines.yield | |
import org.junit.Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import kotlinx.coroutines.CompletableDeferred | |
import kotlinx.coroutines.CoroutineScope | |
import kotlinx.coroutines.Dispatchers | |
import kotlinx.coroutines.InternalCoroutinesApi | |
import kotlinx.coroutines.SupervisorJob | |
import kotlinx.coroutines.cancel | |
import kotlinx.coroutines.channels.Channel | |
import kotlinx.coroutines.channels.Channel.Factory.UNLIMITED | |
import kotlinx.coroutines.launch | |
import kotlinx.coroutines.suspendCancellableCoroutine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.leetzone.android.yatselibs.client.xbmceden; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.net.InetAddress; | |
import java.util.Stack; | |
import org.leetzone.android.utils.Logger; | |
import org.leetzone.android.yatselibs.client.xbmceden.eventclient.Packet; | |
import org.leetzone.android.yatselibs.client.xbmceden.eventclient.PacketACTION; |