<commit_before>//
//  Dispatch.swift
//  THGDispatch
//
//  Created by <NAME> on 2/18/15.
//  Copyright (c) 2015 TheHolyGrail. All rights reserved.
//

import Foundation

public struct Dispatch {
    
    public init() {
        
    }
    
    public func async(queue: DispatchQueue, closure: () -> Void) -> DispatchClosure {
        let wrappedClosure = DispatchClosure(closure)
        dispatch_async(queue.dispatchQueue(), wrappedClosure.dispatchClosure())
        return wrappedClosure
    }
    
    public func sync(queue: DispatchQueue, closure: () -> Void) -> DispatchClosure {
        let wrappedClosure = DispatchClosure(closure)
        dispatch_sync(queue.dispatchQueue(), wrappedClosure.dispatchClosure())
        return wrappedClosure
    }
    
    public func after(queue: DispatchQueue, delay: NSTimeInterval, closure: () -> Void) -> DispatchClosure {
        let wrappedClosure = DispatchClosure(closure)
        let dispatchDelay = dispatch_time(DISPATCH_TIME_NOW, Int64(delay * NSTimeInterval(NSEC_PER_SEC)))
        dispatch_after(dispatchDelay, queue.dispatchQueue(), wrappedClosure.dispatchClosure())
        return wrappedClosure
    }
    
    public func barrierAsync(queue: DispatchQueue, closure: () -> Void) -> DispatchClosure {
        let wrappedClosure = DispatchClosure(closure)
        dispatch_barrier_async(queue.dispatchQueue(), wrappedClosure.dispatchClosure())
        return wrappedClosure
    }
    
    public func barrierSync(queue: DispatchQueue, closure: () -> Void) -> DispatchClosure {
        let wrappedClosure = DispatchClosure(closure)
        dispatch_barrier_sync(queue.dispatchQueue(), wrappedClosure.dispatchClosure())
        return wrappedClosure
    }
    
    public func suspend(queue: DispatchQueue) {
        switch queue {
        case .Custom(let rawQueue):
            dispatch_suspend(rawQueue)
        default:
            assertionFailure("You can only suspend custom queues, not system queues!")
        }
    }
    
    public func resume(queue: DispatchQueue) {
        switch queue {
        case .Custom(let rawQueue):
            dispatch_resume(rawQueue)
        default:
            assertionFailure("You can only suspend custom queues, not system queues!")
        }
    }
    
}<commit_msg>Switched to exceptionFailure from assertionFailure.<commit_after>//
//  Dispatch.swift
//  THGDispatch
//
//  Created by <NAME> on 2/18/15.
//  Copyright (c) 2015 TheHolyGrail. All rights reserved.
//

import Foundation
import THGFoundation

public struct Dispatch {
    
    public init() {
        
    }
    
    public func async(queue: DispatchQueue, closure: () -> Void) -> DispatchClosure {
        let wrappedClosure = DispatchClosure(closure)
        dispatch_async(queue.dispatchQueue(), wrappedClosure.dispatchClosure())
        return wrappedClosure
    }
    
    public func sync(queue: DispatchQueue, closure: () -> Void) -> DispatchClosure {
        let wrappedClosure = DispatchClosure(closure)
        dispatch_sync(queue.dispatchQueue(), wrappedClosure.dispatchClosure())
        return wrappedClosure
    }
    
    public func after(queue: DispatchQueue, delay: NSTimeInterval, closure: () -> Void) -> DispatchClosure {
        let wrappedClosure = DispatchClosure(closure)
        let dispatchDelay = dispatch_time(DISPATCH_TIME_NOW, Int64(delay * NSTimeInterval(NSEC_PER_SEC)))
        dispatch_after(dispatchDelay, queue.dispatchQueue(), wrappedClosure.dispatchClosure())
        return wrappedClosure
    }
    
    public func barrierAsync(queue: DispatchQueue, closure: () -> Void) -> DispatchClosure {
        let wrappedClosure = DispatchClosure(closure)
        dispatch_barrier_async(queue.dispatchQueue(), wrappedClosure.dispatchClosure())
        return wrappedClosure
    }
    
    public func barrierSync(queue: DispatchQueue, closure: () -> Void) -> DispatchClosure {
        let wrappedClosure = DispatchClosure(closure)
        dispatch_barrier_sync(queue.dispatchQueue(), wrappedClosure.dispatchClosure())
        return wrappedClosure
    }
    
    public func suspend(queue: DispatchQueue) {
        switch queue {
        case .Custom(let rawQueue):
            dispatch_suspend(rawQueue)
        default:
            exceptionFailure("You can only suspend custom queues, not system queues!")
        }
    }
    
    public func resume(queue: DispatchQueue) {
        switch queue {
        case .Custom(let rawQueue):
            dispatch_resume(rawQueue)
        default:
            exceptionFailure("You can only suspend custom queues, not system queues!")
        }
    }
    
}
{'fraction_non_alphanumeric': 0.09158146617359147, 'fraction_numerical': 0.004785729823798129, 'mean_word_length': 2.8380634390651087, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '209475', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1246, 'n_words': 286}