mirror of https://github.com/vapor/docs.git
616 B
616 B
Core
Core provides some conveniences for common tasks.
Background
Easily create a background thread using background()
print("hello")
try background {
print("world")
}
Portal
Portals allow you to make async tasks blocking.
let result = try Portal.open { portal in
someAsyncTask { result in
portal.close(with: result)
}
}
print(result) // the result from the async task
RFC1123
Create RFC1123 type dates.
let now = Date().rfc1123 // string
You can also parse RFC1123 strings.
let parsed = Date(rfc1123: "Mon, 10 Apr 2017 11:26:13 GMT")