OTAtomics - Multi-platform Swift thread-safe atomics library

Overview

OTAtomics

CI Build Status Platforms - macOS | iOS | tvOS | watchOS License: MIT

Multi-platform Swift thread-safe atomics library.

The library has full unit test coverage and is actively used in production.

Installation: Swift Package Manager (SPM)

Dependency within an Application

  1. Add the package to your Xcode project using Swift Package Manager
    • Select File → Swift Packages → Add Package Dependency
    • Add package using https://github.com/orchetect/OTAtomics as the URL.
  2. Import the module in your *.swift files where needed.
    import OTAtomics

Dependency within a Swift Package

  1. In your Package.swift file:

    dependencies: [
        .package(url: "https://github.com/orchetect/OTAtomics", from: "1.0.0")
    ],
  2. @_implementationOnly prevents the methods and properties in OTAtomics from being exported to the consumer of your SPM package.

    @_implementationOnly import OTAtomics

Documentation

Most methods are implemented as category methods so they are generally discoverable.

All methods have inline help explaining their purpose and basic usage examples.

Author

Coded by a bunch of 🐹 hamsters in a trenchcoat that calls itself @orchetect.

License

Licensed under the MIT license. See LICENSE for details.

Contributions

Bug fixes and improvements are welcome. Please open an issue to discuss prior to submitting PRs.

You might also like...
Safe and fast access to SwiftUI PreviewDevice

SafePreviewDevice Motivation At WWDC 2019, Apple announced SwiftUI a new library for building UI in a simple and fast way. Xcode’s SwiftUI preview let

swift-highlight a pure-Swift data structure library designed for server applications that need to store a lot of styled text

swift-highlight is a pure-Swift data structure library designed for server applications that need to store a lot of styled text. The Highlight module is memory-efficient and uses slab allocations and small-string optimizations to pack large amounts of styled text into a small amount of memory, while still supporting efficient traversal through the Sequence protocol.

macOS system library in Swift

SystemKit A macOS system library in Swift based off of libtop, from Apple's top implementation. For an example usage of this library, see dshb, a macO

Swift library to develop custom Alexa Skills
Swift library to develop custom Alexa Skills

AlexaSkillsKit AlexaSkillsKit is a Swift library that allows you to develop custom skills for Amazon Alexa, the voice service that powers Echo. It tak

Focus is an Optics library for Swift (where Optics includes Lens, Prisms, and Isos)

Focus Focus is an Optics library for Swift (where Optics includes Lens, Prisms, and Isos) that is inspired by Haskell's Lens library. Introduction Foc

A Swift micro library for generating Sunrise and Sunset times.

Solar A Swift helper for generating Sunrise and Sunset times. Solar performs its calculations locally using an algorithm from the United States Naval

Plugin and runtime library for using protobuf with Swift

Swift Protobuf Welcome to Swift Protobuf! Apple's Swift programming language is a perfect complement to Google's Protocol Buffer ("protobuf") serializ

A Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and other native frameworks.
A Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and other native frameworks.

ZamzamKit ZamzamKit is a Swift package for rapid development using a collection of micro utility extensions for Standard Library, Foundation, and othe

noppefoxwolf/notion is a notion.so API library written in swift.
noppefoxwolf/notion is a notion.so API library written in swift.

notion noppefoxwolf/notion is a notion.so API library written in swift. Installation Xcode Project Swift Packages [email protected]:noppefoxwolf/notion

Comments
  • Memory leaks

    Memory leaks

    I'm putting this here until I have time to look at it, or if you would like to look at it.

    image image
    <OTAtomicsThreadSafe<Optional<String>>: 0x600003d17e30>
    
    opened by ryanfrancesconi 1
  • `@OTAtomicsThreadSafe` wrapper not usable on local var within a method

    `@OTAtomicsThreadSafe` wrapper not usable on local var within a method

    Issue

    In its current implementation, @OTAtomicsThreadSafe is designed to work as a wrapper around variables installed in an object (class, struct, enum, etc.).

    success

    However it will strangely result in a data race when used on a variable declaration within a function. So this wrapper should not be used in this fashion.

    The following code will almost always return a value that is less than 100:

    fail

    Proposal

    It is poor form to declare a local variable within a function and then attempt to mutate it concurrently. Better form is to take the value and pass it into a concurrent operation that can run synchronously within the method, then rely on the operation to return the fully mutated value, often by way of a completion handler closure which can be waited on.

    It is not clear if there is a way to prevent the property wrapper from being used on variable declarations inside a method, as the compiler will not stop you from doing it.

    enhancement 
    opened by orchetect 3
Releases(1.0.0)
Owner
Steffan Andrews
Coding since 1995. Professional composer for film & TV.
Steffan Andrews
Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. (Pure Swift, Supports Linux)

SwiftFoundation Cross-Platform, Protocol-Oriented Programming base library to complement the Swift Standard Library. Goals Provide a cross-platform in

null 620 Oct 11, 2022
🏹 Bow is a cross-platform library for Typed Functional Programming in Swift

Bow is a cross-platform library for Typed Functional Programming in Swift. Documentation All documentation and API reference is published in our websi

Bow 613 Dec 20, 2022
A cross-platform library of Swift utils to ease your iOS | macOS | watchOS | tvOS and Linux development.

Mechanica A library of Swift utils to ease your iOS, macOS, watchOS, tvOS and Linux development. Requirements Documentation Installation License Contr

Alessandro 28 Aug 28, 2022
🚀Comprehensive Redux library for SwiftUI, ensures State consistency across Stores with type-safe pub/sub pattern.

??Comprehensive Redux library for SwiftUI, ensures State consistency across Stores with type-safe pub/sub pattern.

Cheng Zhang 18 Mar 9, 2022
MediaType is a library that can be used to create Media Types in a type-safe manner.

This is a general purpose Swift library for a concept of typed treatment for Media Types. We use this library on clients and servers to speak the same dialect and to enjoy all the comfort strong types provide over raw strings.

21Gram Consulting 79 Jul 19, 2022
A Flutter plugin (platform channel with Swift) to get the current app name and also bring our app to the front.

window_to_front A new flutter plugin project. Getting Started This project is a starting point for a Flutter plug-in package, a specialized package th

Minas Giannekas 1 Nov 13, 2021
Type-Safe Associated Objects in Swift

Type-Safe Associated Objects in Swift TSAO is an implementation of type-safe associated objects in Swift. Objective-C associated objects are useful, b

Lily Ballard 135 Dec 21, 2022
Swift package for accessing SF Symbols in a type safe manner.

Swift Package Information Code Coverage Swift package for accessing SF Symbols in a type safe manner. Features ?? Contains all SF Symbols - 1.0, 2.0,

null 6 Dec 7, 2021
Generic Cross Platform Signal Handler

Signals Generic Cross Platform Signal Handler. Prerequisites Swift Swift Open Source swift-4.0.0-RELEASE toolchain (Minimum REQUIRED for latest releas

Kitura 91 Oct 2, 2022
The sample implementation of zip-archived document for a macOS AppKit platform.

The sample implementation of zip-archived document for a macOS AppKit platform. You can implement NSDocument-based I/O of archived document in your application like .sketch or .key.

usagimaru 4 Nov 12, 2022