This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2017 The Android Open Source Project | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// AppDelegate.swift | |
// Scheduling | |
// | |
// Created by Shaps Benkau on 19/02/2018. | |
// Copyright © 2018 152percent Ltd. All rights reserved. | |
// | |
import UIKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
public class MessageQueue { | |
public typealias Message = Void -> Void | |
private var exitFlag = false | |
private var messageQueue:[Message] = [] | |
private var loopInterval:Double |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Channel<Value> { | |
private class Subscription { | |
weak var object: AnyObject? | |
private let notifyBlock: (Value) -> Void | |
private let queue: DispatchQueue | |
var isValid: Bool { | |
return object != nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum HTTPStatusCode: Int { | |
// MARK: - 100 Informational | |
case Continue = 100 | |
case SwitchingProtocols | |
case Processing | |
// MARK: - 200 Success | |
case Ok = 200 | |
case Created | |
case Accepted | |
case NonAuthoritativeInformation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// UIAccessorizedTextField.swift | |
// AccessorizedTextField | |
// | |
// Created by Damien Laughton on 28/03/2018. | |
// 2018 Mobilology Limited. No rights reserved. | |
// | |
import Foundation | |
import UIKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import PlaygroundSupport | |
/// A thread-safe array. | |
public class SynchronizedArray<Element> { | |
fileprivate let queue = DispatchQueue(label: "io.zamzam.ZamzamKit.SynchronizedArray", attributes: .concurrent) | |
fileprivate var array = [Element]() | |
} | |
// MARK: - Properties |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import PlaygroundSupport | |
/// A thread-safe array. | |
public class SynchronizedArray<Element> { | |
fileprivate let queue = DispatchQueue(label: "io.zamzam.ZamzamKit.SynchronizedArray", attributes: .concurrent) | |
fileprivate var array = [Element]() | |
} | |
// MARK: - Properties |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CoreData | |
/// Manages Core Data Persistent History. | |
/// | |
/// When using Core Data in multiple targets, e.g. an app as well as a file provider, it is crucial to merge changes from one | |
/// target into another because otherwise you would end up with inconsistent state. To that end, this Apple introduced | |
/// persistent history, which is a linear stream of changes that can be merged into the current context. This service takes | |
/// advantage of this feature by providing a simple interface for merging and deleting history. The latter is needed to free up | |
/// space after the history has been consumed by all targets. It uses history transactions' timestamps in order to determine | |
/// what to delete. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Multi to single thread execution | |
// Credits go to https://www.reddit.com/r/swift/comments/7ijbt0/whats_a_good_way_to_make_sync_calls_from_swift_to/dr4iwxr/ | |
import Foundation | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(3000)) { | |
print("Done") | |
PlaygroundPage.current.finishExecution() |