File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -15,13 +15,18 @@ import Foundation
1515
1616infix operator <~ { associativity none precedence 130 }
1717
18+ private let lock = dispatch_semaphore_create ( 1 )
1819private var swiftRegexCache = [ String: NSRegularExpression] ( )
1920
2021internal final class SwiftRegex : NSObject , BooleanType {
2122 var target : String
2223 var regex : NSRegularExpression
2324
2425 init ( target: String , pattern: String , options: NSRegularExpressionOptions ? ) {
26+ if dispatch_semaphore_wait ( lock, dispatch_time ( DISPATCH_TIME_NOW, Int64 ( 10 * NSEC_PER_MSEC) ) ) != 0 {
27+ fatalError ( " This should never happen " )
28+ }
29+
2530 self . target = target
2631 if let regex = swiftRegexCache [ pattern] {
2732 self . regex = regex
@@ -36,6 +41,7 @@ internal final class SwiftRegex: NSObject, BooleanType {
3641 self . regex = NSRegularExpression ( )
3742 }
3843 }
44+ dispatch_semaphore_signal ( lock)
3945 super. init ( )
4046 }
4147
You can’t perform that action at this time.
0 commit comments