struct Queue < T > { private var elements : [ T ] = [] mutating func enqueue ( _ value : T ) { elements . struct Queue < T > { private let queue = DispatchQueue ( label : "queue.operations" ) private var elements : [ T ] = [] mutating func enqueue ( _ value : T ) { queue . We can improve this using a concurrent queue with barrier to sync write access on that specific queue and turn those two properties atomic.