0001 #if os(Linux) 0002 import Glibc 0003 #else 0004 import Darwin 0005 #endif 0006 0007 final class MainQueue{ 0008 0009 let identifier
Echo.swift:9 let mainQueue: MainQueueEcho.swift:13 mainQueue = MainQueue(identifier:"com.queue.main")MainQueue.swift:30 extension MainQueue: DispatchQueue {: String 0010 0011 var events
MainQueue.swift:22 self.identifier = identifier: [() -> ()] 0012 0013 var eventMutex
MainQueue.swift:23 events = []MainQueue.swift:48 while events.count > 0 {MainQueue.swift:50 let event = events.removeFirst(): pthread_mutex_t 0014 0015 var eventCondition
MainQueue.swift:24 eventMutex = pthread_mutex_t()MainQueue.swift:38 pthread_mutex_init(&eventMutex, nil)MainQueue.swift:49 pthread_mutex_lock(&eventMutex)MainQueue.swift:51 pthread_mutex_unlock(&eventMutex): pthread_cond_t 0016 0017 var running
MainQueue.swift:25 eventCondition = pthread_cond_t()MainQueue.swift:42 pthread_cond_init (&eventCondition, nil)MainQueue.swift:55 pthread_cond_wait(&eventCondition, &conditionMutex)MainQueue.swift:61 pthread_cond_signal(&eventCondition): Bool 0018 0019 init
MainQueue.swift:26 running = falseMainQueue.swift:34 running = trueMainQueue.swift:46 while running {MainQueue.swift:60 running = false(identifier: String) { 0020 0021 self.identifier = identifier 0022 events = [] 0023 eventMutex = pthread_mutex_t() 0024 eventCondition = pthread_cond_t() 0025 running = false 0026 } 0027 } 0028 0029 extension MainQueue: DispatchQueue { 0030 0031 func run() { 0032 0033 running = true 0034 0035 var conditionMutex = pthread_mutex_t() 0036 0037 pthread_mutex_init(&eventMutex, nil) 0038 0039 pthread_mutex_init(&conditionMutex, nil) 0040 0041 pthread_cond_init (&eventCondition, nil) 0042 0043 pthread_mutex_lock(&conditionMutex) 0044 0045 while running { 0046 0047 while events.count > 0 { 0048 pthread_mutex_lock(&eventMutex) 0049 let event = events.removeFirst() 0050 pthread_mutex_unlock(&eventMutex) 0051 event() 0052 } 0053 0054 pthread_cond_wait(&eventCondition, &conditionMutex) 0055 } 0056 } 0057 0058 func exit() { 0059 running = false 0060 pthread_cond_signal(&eventCondition) 0061 } 0062 } 0063
Echo.swift:13 mainQueue = MainQueue(identifier:"com.queue.main")