# Path: rx/concurrency.py
# class Atomic:
#   def __init__(self, value=None, lock=RLock()):
#     self.lock = lock
#     self._value = value
# 
#   def value():
#       doc = "The value property."
#       def fget(self):
#           return self._value
#       def fset(self, value):
#           self.exchange(value)
#       return locals()
#   value = property(**value())
# 
#   def exchange(self, value):
#     with self.lock:
#       old = self._value
#       self._value = value
#       return old
# 
#   def compareExchange(self, value, expected):
#     with self.lock:
#       old = self._value
# 
#       if old == expected:
#         self._value = value
# 
#       return old
# 
#   def inc(self, by=1):
#     with self.lock:
#       self._value += by
#       return self.value
# 
#   def dec(self, by=1):
#     with self.lock:
#       self._value -= by
#       return self.value


from rx.concurrency import Atomic
from collections import deque
    with self.lock:
      if self.isDisposed or self.isPrimaryDisposed:
        return

      self.isPrimaryDisposed = True

      if self.count == 0:
        disposable = self.disposable
        self._isDisposed.value = True

    if disposable != None:
      disposable.dispose()

  def getDisposable(self):
    with self.lock:
      if self.isDisposed:
        return Disposable.empty()
      else:
        self.count += 1
        return self.InnerDisposable(self)

  def release(self):
    disposable = None

    with self.lock:
      if self.isDisposed:
        return

      self.count -= 1


# Path: rx/concurrency.py
# class Atomic:
#   def __init__(self, value=None, lock=RLock()):
#     self.lock = lock
#     self._value = value
# 
#   def value():
#       doc = "The value property."
#       def fget(self):
#           return self._value
#       def fset(self, value):
#           self.exchange(value)
#       return locals()
#   value = property(**value())
# 
#   def exchange(self, value):
#     with self.lock:
#       old = self._value
#       self._value = value
#       return old
# 
#   def compareExchange(self, value, expected):
#     with self.lock:
#       old = self._value
# 
#       if old == expected:
#         self._value = value
# 
#       return old
# 
#   def inc(self, by=1):
#     with self.lock:
#       self._value += by
#       return self.value
# 
#   def dec(self, by=1):
#     with self.lock:
#       self._value -= by
#       return self.value


# Path: rx/disposable.py
from rx.concurrency import Atomic
from collections import deque

    with self.lock:
      if self.isDisposed or self.isPrimaryDisposed:
        return

      self.isPrimaryDisposed = True

      if self.count == 0:
        disposable = self.disposable
        self._isDisposed.value = True

    if disposable != None:
      disposable.dispose()

  def getDisposable(self):
    with self.lock:
      if self.isDisposed:
        return Disposable.empty()
      else:
        self.count += 1
        return self.InnerDisposable(self)

  def release(self):
    disposable = None

    with self.lock:
      if self.isDisposed:
        return

      self.count -= 1


      if self.isPrimaryDisposed and self.count == 0: