[swift-users] Swift Concurrency and Actor model

Greg Parker gparker at apple.com
Tue Apr 11 17:37:06 CDT 2017

> On Apr 11, 2017, at 9:10 AM, Gerard Iglesias via swift-users <swift-users at swift.org> wrote:
> Thanx for the link on this…
> I am experimenting the use of dispatch queue to mimic somme Actor Model things and it is not a bad idea, dispatch queue are perfect for that.
> I wonder what is the scalability of the Dispatch layer, are we able to create a bunch of dispatch queue without putting the system on its knees ? I will do tests

Dispatch queues are intended to be cheap, comparable to a pthread_mutex IIRC.

The limited resource are the top-level global queues, DispatchQueue.main and DispatchQueue.global(…). There are a limited number of threads available to service concurrent items on those queues (around 500 threads on macOS and iOS, IIRC). If too many concurrent work items are pushed into the global queues at one time then the process may deadlock when dispatch exhausts its thread pool.

Greg Parker     gparker at apple.com <mailto:gparker at apple.com>     Runtime Wrangler

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170411/1b380216/attachment.html>

More information about the swift-users mailing list