<commit_before>/*
* Select (select.swift) - Please be Safe
*
* Copyright (C) 2015 ONcast, LLC. All Rights Reserved.
* Created by <NAME> (<EMAIL>)
*
* This software may be modified and distributed under the terms
* of the MIT license.  See the LICENSE file for details.
*/

#if os(Linux)
import Glibc
#endif

import Foundation

private protocol ItemAny {
    func register(cond: Cond)
    func unregister(cond: Cond)
    func get() -> Bool;
    func call()
}

private class Item<T> : ItemAny {
    var closed = false
    var msg : T?
    var chan : Chan<T>?
    var caseBlock : ((T?)->())?
    var defBlock : (()->())?
    init(_ chan: Chan<T>?, _ caseBlock: ((T?)->())?, _ defBlock: (()->())?){
        (self.chan, self.caseBlock, self.defBlock) = (chan, caseBlock, defBlock)
    }
    func register(cond: Cond){
        if let chan = chan {
            chan.cond.mutex.lock()
            defer { chan.cond.mutex.unlock() }
            chan.gconds += [cond]
        }
    }
    func unregister(cond: Cond){
        if let chan = chan {
            chan.cond.mutex.lock()
            defer { chan.cond.mutex.unlock() }
            for i in 0...chan.gconds.count {
                if chan.gconds[i] === cond {
                    chan.gconds.removeAtIndex(i)
                    return
                }
            }
        }
    }
    func get() -> Bool {<commit_msg>Ubuntu ready<commit_after>/*
* Select (select.swift) - Please be Safe
*
* Copyright (C) 2015 ONcast, LLC. All Rights Reserved.
* Created by <NAME> (<EMAIL>)
*
* This software may be modified and distributed under the terms
* of the MIT license.  See the LICENSE file for details.
*/

#if os(Linux)
import Glibc
#endif

import Foundation

private protocol ItemAny {
    func register(cond: Cond)
    func unregister(cond: Cond)
    func get() -> Bool;
    func call()
}

private class Item<T> : ItemAny {
    var closed = false
    var msg : T?
    var chan : Chan<T>?
    var caseBlock : ((T?)->())?
    var defBlock : (()->())?
    init(_ chan: Chan<T>?, _ caseBlock: ((T?)->())?, _ defBlock: (()->())?){
        (self.chan, self.caseBlock, self.defBlock) = (chan, caseBlock, defBlock)
    }
    func register(cond: Cond){
        if let chan = chan {
            chan.cond.mutex.lock()
            defer { chan.cond.mutex.unlock() }
            chan.gconds += [cond]
        }
    }
    func unregister(cond: Cond){
        if let chan = chan {
            chan.cond.mutex.lock()
            defer { chan.cond.mutex.unlock() }
            for i in 0..<chan.gconds.count {
                if chan.gconds[i] === cond {
                    chan.gconds.removeAtIndex(i)
                    return
                }
            }
        }
    }
    func get() -> Bool {
{'fraction_non_alphanumeric': 0.14186471663619743, 'fraction_numerical': 0.003656307129798903, 'mean_word_length': 1.9075451647183848, 'pattern_counts': {'":': 0, '<': 14, '<?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': '4289952', 'n_tokens_mistral': 912, 'n_tokens_neox': 848, 'n_words': 247}