This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
func randomDelay(maxDuration: Double) { | |
let randomWait = UInt32.random(in: 0..<UInt32(maxDuration * Double(USEC_PER_SEC))) | |
usleep(randomWait) | |
} | |
let isolationQueue = DispatchQueue(label: "com.myproject.atm.isolation", | |
attributes: .concurrent) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Bank.swift | |
// | |
// Created by Laura Pinheiro Marson on 25/07/23. | |
// | |
import Foundation | |
func randomDelay(maxDuration: Double) { | |
let randomWait = UInt32.random(in: 0..<UInt32(maxDuration * Double(USEC_PER_SEC))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
let concurrentQueue = DispatchQueue.global() | |
var counter = 0 | |
concurrentQueue.async { | |
for n in 0..<100 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import PlaygroundSupport | |
///Habilite a execução indefinida do playground para evitar que as tasks executadas em background sejam interrompidas quando a main thread for finalizada. | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
///Criando uma private queue concorrente | |
let concurrentQueueA = DispatchQueue(label: "com.myproject.concurrent", | |
qos: .utility, | |
attributes: .concurrent) |