Martin Gagnon
09/08/2020, 4:30 PMopen class IOSSerialDispatchQueue(identifier: String) : DispatchQueue {
private val serialQueue = dispatch_queue_create(
"com.mirego.trikot.foundation.serial_dispatch_queue.$identifier",
dispatch_queue_serial_t()
)
override fun isSerial() = true
override fun dispatch(block: DispatchBlock) {
freeze(block)
dispatch_async(serialQueue, freeze {
runQueueTask(block)
})
}
private fun runQueueTask(block: DispatchBlock) {
block()
}
}
The crash happens in class initialization at line dispatch_queue_create("...", dispatch_queue_serial_t())
. I can reproduce with the following swift code let _ = IOSSerialDispatchQueue(identifier: "None")
in my AppDelegate.swift file . The crash is EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
(Kotlin 1.4)svyatoslav.scherbina
09/09/2020, 3:16 PMI don’t think this should actually work.dispatch_queue_serial_t()
dispatch_queue_serial_t
is just a typealias
for NSObject
, so dispatch_queue_serial_t()
is an NSObject
.
Please refer to the documentation for details on valid values for the second parameter of dispatch_queue_create
.