Moves all Dispatchers.Default to IO because of the amount of Synchronized code that blocks the thread underneath each coroutine and since Default only has the exact number of threads the processor offers, once they block, we lose computing power
This commit is contained in:
+2
-2
@@ -108,7 +108,7 @@ class NostrClient(
|
||||
}.sample(300)
|
||||
.onEach {
|
||||
relayPool.updatePool(it)
|
||||
}.flowOn(Dispatchers.Default)
|
||||
}.flowOn(Dispatchers.IO)
|
||||
.stateIn(
|
||||
scope,
|
||||
SharingStarted.Eagerly,
|
||||
@@ -229,7 +229,7 @@ class NostrClient(
|
||||
|
||||
override fun renewFilters(relay: IRelayClient) {
|
||||
if (isActive) {
|
||||
scope.launch(Dispatchers.Default) {
|
||||
scope.launch(Dispatchers.IO) {
|
||||
activeRequests.syncState(relay.url, relay::sendOrConnectAndSync)
|
||||
activeCounts.syncState(relay.url, relay::sendOrConnectAndSync)
|
||||
eventOutbox.syncState(relay.url, relay::sendOrConnectAndSync)
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ class BasicOkHttpWebSocket(
|
||||
|
||||
val listener =
|
||||
object : OkHttpWebSocketListener() {
|
||||
val scope = CoroutineScope(Dispatchers.Default + exceptionHandler)
|
||||
val scope = CoroutineScope(Dispatchers.IO + exceptionHandler)
|
||||
val incomingMessages: Channel<String> = Channel(Channel.UNLIMITED)
|
||||
val job = // Launch a coroutine to process messages from the channel.
|
||||
scope.launch {
|
||||
|
||||
Reference in New Issue
Block a user