File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
app/src/main/java/com/osfans/trime/core Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ class RimeDispatcher(
5555 }
5656
5757 override fun toString (): String = " WrappedRunnable[${name ? : hashCode()} ]"
58+
59+ companion object {
60+ val Empty = WrappedRunnable ({}, " Empty" )
61+ }
5862 }
5963
6064 companion object {
@@ -105,6 +109,7 @@ class RimeDispatcher(
105109 Timber .i(" RimeDispatcher stop()" )
106110 return if (isRunning.compareAndSet(true , false )) {
107111 runBlocking {
112+ queue.offer(WrappedRunnable .Empty )
108113 mutex.withLock {
109114 val rest = mutableListOf<WrappedRunnable >()
110115 queue.drainTo(rest)
@@ -123,6 +128,6 @@ class RimeDispatcher(
123128 if (! isRunning.get()) {
124129 throw IllegalStateException (" Dispatcher is not in running state!" )
125130 }
126- queue.put (WrappedRunnable (block))
131+ queue.offer (WrappedRunnable (block))
127132 }
128133}
You can’t perform that action at this time.
0 commit comments