942v / swift-concurrency

Concurrency utilities for Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Swift Concurrency

Build Status Carthage compatible License

Contents

Requirements

  • Xcode 9.3+
  • Swift 4.0+

Overview

A set of concurrency utility classes used by Uber. These are largely inspired by the equivalent java.util.concurrent package classes.

AtomicBool

Provides locking-free synchronization of a mutable Bool. It provides higher performance than using locks to ensure thread-safety and synchronization correctness.

AtomicInt

Provides locking-free synchronization of a mutable Int. It provides higher performance than using locks to ensure thread-safety and synchronization correctness.

AtomicReference

Provides locking-free synchronization of a mutable object reference. It provides higher performance than using locks to ensure thread-safety and synchronization correctness.

CountDownLatch

A utility class that allows coordination between threads. A count down latch starts with an initial count. Threads can then decrement the count until it reaches zero, at which point, the suspended waiting thread shall proceed. A CountDownLatch behaves differently from a DispatchSemaphore once the latch is open. Unlike a semaphore where subsequent waits would still block the caller thread, once a CountDownLatch is open, all subsequent waits can directly passthrough.

ConcurrentSequenceExecutor

An execution utility that executes sequences of tasks and returns the final result in a highly concurrent environment.

SerialSequenceExecutor

A debugging executor that executes sequences of tasks and returns the final result serially on the caller thread.

Installation

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with dylib frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Swift-Concurrency into your Xcode project using Carthage, specify it in your Cartfile:

github "https://github.com/uber/swift-concurrency.git" ~> 0.4.0

Run carthage update to build the framework and add the built Concurrency.framework into your Xcode project, by following the instructions

Manually

If you prefer not to use Carthage, you can integrate Swift-Concurrency into your project manually, by adding the source files.

Building

First fetch the dependencies:

$ swift package fetch

You can then build from the command-line:

$ swift build

Or create an Xcode project and build using the IDE:

$ swift package generate-xcodeproj

Testing

From command-line.

$ swift test

Or you can follow the steps above to generate a Xcode project and run tests within Xcode.

Related projects

If you like Needle, check out other related open source projects from our team:

  • Needle: a compile-time safe Swift dependency injection framework.
  • Swift Abstract Class: a light-weight library along with an executable that enables compile-time safe abstract class development for Swift projects.
  • Swift Common: common libraries used by this set of Swift open source projects.

License

FOSSA Status

About

Concurrency utilities for Swift

License:Apache License 2.0


Languages

Language:Swift 93.9%Language:Objective-C 4.4%Language:Ruby 1.7%