I'm trying to understand how Swift 4.0 asynchronous processing works in Linux.
After looking at the documentation and some answers on SO I came up with this simple example:
import Dispatch
import Glibc
DispatchQueue.main.asyncAfter(deadline: .now()) {
print("Done!")
}
print("Sleeping for 2 seconds...")
usleep(2 * 1_000_000)
print("Exiting...")
However, this only prints:
Sleeping for 2 seconds...
Exiting...
Why does it not print Done!
? What am I missing? How do I write a simple parallel processing example?