<commit_before>//
//  SingleAssignmentDisposable.swift
//  RxSwift
//
//  Created by <NAME> on 2/15/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

/**
Represents a disposable resource which only allows a single assignment of its underlying disposable resource.

If an underlying disposable resource has already been set, future attempts to set the underlying disposable resource will throw an exception.
*/
public final class SingleAssignmentDisposable : DisposeBase, Cancelable {

    private enum DisposeState: Int32 {
        case disposed = 1
        case disposableSet = 2
    }

    // state
    private let state = AtomicInt(0)
    private var disposable = nil as Disposable?

    /// - returns: A value that indicates whether the object is disposed.<commit_msg>using OptionSet instead of  enum for DisposeState (#2336)<commit_after>//
//  SingleAssignmentDisposable.swift
//  RxSwift
//
//  Created by <NAME> on 2/15/15.
//  Copyright © 2015 <NAME>. All rights reserved.
//

/**
Represents a disposable resource which only allows a single assignment of its underlying disposable resource.

If an underlying disposable resource has already been set, future attempts to set the underlying disposable resource will throw an exception.
*/
public final class SingleAssignmentDisposable : DisposeBase, Cancelable {

    private struct DisposeState: OptionSet {
        let rawValue: Int32
        
        static let disposed = DisposeState(rawValue: 1 << 0)
        static let disposableSet = DisposeState(rawValue: 1 << 1)
    }

    // state
    private let state = AtomicInt(0)
    private var disposable = nil as Disposable?

    /// - returns: A value that indicates whether the object is disposed.
{'fraction_non_alphanumeric': 0.07454863133372161, 'fraction_numerical': 0.019801980198019802, 'mean_word_length': 3.2004889975550124, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, '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': '4818370', 'n_tokens_mistral': 485, 'n_tokens_neox': 426, 'n_words': 191}