<commit_before>//
//  PKNetworkActivityController.swift
//  PKNetworkActivityController
//
//  Created by <NAME> on 6/19/14.
//  Copyright (c) 2014 NSExceptional. All rights reserved.
//

import Foundation

class PKNetworkActivityController: NSObject {
    
    class var sharedController: PKNetworkActivityController {
        return Constants.sharedController
    }
    
    /// The number of activities in progress. Iff the number is greater than 0, the network activity indicator is visible (unless modified by an external source).
    var numberOfRegisteredActivities: Int = 0
    
    /// Registers for network activity.
    func registerActivity() {
        withUnsafePointer(&spinLock, OSSpinLockLock)
        
        numberOfRegisteredActivities += 1
        if numberOfRegisteredActivities > 0 {
            UIApplication.sharedApplication().networkActivityIndicatorVisible = true
        }
        
        withUnsafePointer(&spinLock, OSSpinLockUnlock)
    }
    
    /// Deregisters from network activity.
    func deregisterActivity() {
        withUnsafePointer(&spinLock, OSSpinLockLock)
        
        let newValue = numberOfRegisteredActivities - 1
        numberOfRegisteredActivities = newValue >= 0 ? newValue : 0
        if numberOfRegisteredActivities == 0 {
            UIApplication.sharedApplication().networkActivityIndicatorVisible = false
        }
        
        withUnsafePointer(&spinLock, OSSpinLockUnlock)
    }
    
    // #MARK: Private
    
    struct Constants {
        static let sharedController = PKNetworkActivityController.init()
    }
    
    var spinLock = OS_SPINLOCK_INIT
}
<commit_msg>Swifting<commit_after>//
//  PKNetworkActivityController.swift
//  PKNetworkActivityController
//
//  Created by <NAME> on 6/19/14.
//  Copyright (c) 2014 NSExceptional. All rights reserved.
//

import Foundation

@objc class PKNetworkActivityController {
    
    class var sharedController: PKNetworkActivityController {
        return Constants.sharedController
    }
    
    /// The number of activities in progress. Iff the number is greater than 0, the network activity indicator is visible (unless modified by an external source).
    var numberOfRegisteredActivities: Int = 0
    
    /// Registers for network activity.
    func registerActivity() {
        withUnsafePointer(&spinLock, OSSpinLockLock)
        
        numberOfRegisteredActivities += 1
        if numberOfRegisteredActivities > 0 {
            UIApplication.sharedApplication().networkActivityIndicatorVisible = true
        }
        
        withUnsafePointer(&spinLock, OSSpinLockUnlock)
    }
    
    /// Deregisters from network activity.
    func deregisterActivity() {
        withUnsafePointer(&spinLock, OSSpinLockLock)
        
        let newValue = numberOfRegisteredActivities - 1
        numberOfRegisteredActivities = newValue >= 0 ? newValue : 0
        if numberOfRegisteredActivities == 0 {
            UIApplication.sharedApplication().networkActivityIndicatorVisible = false
        }
        
        withUnsafePointer(&spinLock, OSSpinLockUnlock)
    }
    
    // #MARK: Private
    
    struct Constants {
        static let sharedController = PKNetworkActivityController.init()
    }
    
    var spinLock = OS_SPINLOCK_INIT
}

{'fraction_non_alphanumeric': 0.06909202078874961, 'fraction_numerical': 0.010394374808926934, 'mean_word_length': 2.6477146042363433, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '2268987', 'n_tokens_mistral': 872, 'n_tokens_neox': 837, 'n_words': 214}