DEV Community

Coder
Coder

Posted on • Originally published at itscoderslife.wordpress.com on

3 2

Swift meetup

After a long time attended a meetup. And this was on the topic which I work on day to day – Swift programming language.

The meetup overall was good. Got to learn couple of new things – DispatchGroups, Swift Runtime and the thing that we can have our own Swift’s virtual environment just like virtualenv in Python, for swift its called virtualswift.

The most useful talk for me was on measuring performance in swift by Mayur Dhaka in which I can use immediately is DispatchGroups.

DispatchGroup primarily avoids the code shifting to right while using nested blocks like completion handlers.

From what I understood is DispatchGroups are the thing which can be used to group a logical set of background operations into one unit. It has very few APIs. According to Apple :

DispatchGroup().enter() – to indicate the block has entered the group.

DispatchGroup().leave() – to indicate the block in the group has completed.

DispatchGroup().notify(...) – to schedule a block or a work item to be submitted to a queue when a group of previously submitted block objects have completed.

DispatchGroup().wait(...) – waits synchronously for the previously submitted work to complete.

Basically DispatchGroup is to synchronize and track a set of tasks which are logically grouped and executed according to your requirements.

Hope this gist will help you get to know something new and explore more if interested.

swift-small

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more