Commit da4e3330 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Use a threadpool for I/O operations

parent f7bf826f
package org.videolan.vlc.util
import android.os.Looper
import android.os.Process
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.timeunit.TimeUnit
import java.util.concurrent.SynchronousQueue
import java.util.concurrent.ThreadFactory
import java.util.concurrent.ThreadPoolExecutor
val VLCIO = newSingleThreadContext("vlc-io")
//val VLCIO = newSingleThreadContext("vlc-io")
private val THREAD_FACTORY: ThreadFactory = ThreadFactory { runnable ->
Thread(runnable).apply { priority = Thread.NORM_PRIORITY + Process.THREAD_PRIORITY_LESS_FAVORABLE }
val VLCIO = ThreadPoolExecutor(1, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, SynchronousQueue<Runnable>(), THREAD_FACTORY).asCoroutineDispatcher()
private val mainThread = Looper.getMainLooper().thread!!
private val uiDispatch inline get() = mainThread != Thread.currentThread()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment