Skip to content

Instantly share code, notes, and snippets.

View test.kt
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
@Tolriq
Tolriq / OkHttpWorkerPool.kt
Created Nov 14, 2018
OkHttp coroutine WorkerPool with proper exception handling and suspendCancellableCoroutine support.
View OkHttpWorkerPool.kt
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
View EventClient.java
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;