Protocols

The following protocols are available globally.

  • Protocol for objects that have cancellation

    See more

    Declaration

    Swift

    public protocol Cancellable : AnyObject
  • Protocol for concurrency-aware active objects. Conforming to this protocol helps to avoid boilerplate code related to dispatching and memory management. See Moving to nice asynchronous Swift code for complete explanation.

    Best way to conform for model-related classes looks like:

    public class MyService: ExecutionContext, ReleasePoolOwner {
      private let _internalQueue = DispatchQueue(label: "my-service-queue")
      public var executor: Executor { return .queue(_internalQueue) }
      public let releasePool = ReleasePool()
    
      /* class implementation */
    }
    

    Best way to conform for classes related to main queue looks like:

    public class MyMainQueueService: ExecutionContext, ReleasePoolOwner {
      public var executor: Executor { return .main }
      public let releasePool = ReleasePool()
    
      /* class implementation */
    }
    

    Best way to conform for classes related to UI manipulations looks like:

    public class MyPresenter: NSObject, ObjCUIInjectedExecutionContext {
      /* class implementation */
    }
    

    Classes that conform to NSResponder/UIResponder are automatically conformed to exection context.

    See more

    Declaration

    Swift

    public protocol ExecutionContext : Retainer
  • Protocol for any instance that has ReleasePool. Made to proxy calls of func releaseOnDeinit(_ object: AnyObject) and func notifyDeinit(_ block: @escaping () -> Void) to ReleasePool

    See more

    Declaration

    Swift

    public protocol ReleasePoolOwner : Retainer
  • An object that can extend lifetime of another objects up to deinit or notify deinit

    See more

    Declaration

    Swift

    public protocol Retainer : AnyObject
  • Internal use only The combination of protocol _Fallible and enum Fallible is a dirty hack of type system. But there are no higher kinded types or generic protocols to implement it properly. Major propose is an ability to implement flatten() method.

    See more

    Declaration

    Swift

    public protocol _Fallible : CustomStringConvertible
  • Base protocol for objects that can extend lifetime of attached objects up to the moment of finalization (deinit or completion).

    See more

    Declaration

    Swift

    public protocol LifetimeExtender : AnyObject
  • Context indepedent locking. Non-recursive.

    See more

    Declaration

    Swift

    public protocol Locking : AnyObject
  • This protocol helps to hack type system in order to write where clauses for Optional’s wrapped type

    See more

    Declaration

    Swift

    public protocol AsyncNinjaOptionalAdaptor : ExpressibleByNilLiteral