PooledThreadingStrategy

class PooledThreadingStrategy(scope: CoroutineScope = GlobalScope, evictAfter: Duration = 1.minutes) : ThreadingStrategy

A ThreadingStrategy that pools unused "threads" until evictAfter time has elapsed.

In most circumstances, only a a single PooledThreadingStrategy instance should be created per application run, as it holds the "shared" pool of unused "threads".

Useful for when Peripheral connections are quickly being spun down and up again — as they can re-use existing "threads" (acquire their "threads" from the unused pool).

If Peripheral connections are expected to be long running, or for there to be long down times between connections, OnDemandThreadingStrategy may be a better choice.

Constructors

Link copied to clipboard
constructor(scope: CoroutineScope = GlobalScope, evictAfter: Duration = 1.minutes)

Functions

Link copied to clipboard
open override fun acquire(): Threading
Link copied to clipboard
fun cancel()
Link copied to clipboard
open override fun release(threading: Threading)
Link copied to clipboard

Creates Threading that can be used for Bluetooth communication. The returned Threading is returned in a started state and must be shutdown when no longer needed.