<commit_before>package io.reactors



import scala.reflect.ClassTag



/** The reactive cell abstraction represents a mutable memory location
 *  whose changes may produce events.
 *
 *  An `RCell` is conceptually similar to a reactive emitter lifted into a signal.
 *
 *  @tparam T         the type of the values it stores
 *  @param value      the initial value of the reactive cell
 */
class RCell[@spec(Int, Long, Double) T](private var value: T)
extends Signal[T] {
  private var pushSource: Events.PushSource[T] = _

  private[reactors] def init(dummy: RCell[T]) {
    pushSource = new Events.PushSource[T]
  }

  init(this)

  /** Returns the current value in the reactive cell.
   */
  def apply(): T = value

  /** Returns `false`. */
  def isEmpty = false

  /** Does nothing. */
  def unsubscribe() {}

  /** Assigns a new value to the reactive cell,
   *  and emits an event with the new value to all the subscribers.
   *
   *  @param v        the new value
   */
  def :=(v: T): Unit = {
    value = v
    pushSource.reactAll(v, null)
  }

  /** Same as `:=`. */
  def react(x: T) = this := x

  /** Propagates the exception to all the reactors.
   */
  def except(t: Throwable) = pushSource.exceptAll(t)
<commit_msg>Make `RCell` an observer.<commit_after>package io.reactors



import scala.reflect.ClassTag



/** The reactive cell abstraction represents a mutable memory location
 *  whose changes may produce events.
 *
 *  An `RCell` is conceptually similar to a reactive emitter lifted into a signal.
 *
 *  @tparam T         the type of the values it stores
 *  @param value      the initial value of the reactive cell
 */
class RCell[@spec(Int, Long, Double) T](private var value: T)
extends Signal[T] with Observer[T] {
  private var pushSource: Events.PushSource[T] = _

  private[reactors] def init(dummy: RCell[T]) {
    pushSource = new Events.PushSource[T]
  }

  init(this)

  /** Returns the current value in the reactive cell.
   */
  def apply(): T = value

  /** Returns `false`. */
  def isEmpty = false

  /** Does nothing. */
  def unsubscribe() {}

  /** Assigns a new value to the reactive cell,
   *  and emits an event with the new value to all the subscribers.
   *
   *  @param v        the new value
   */
  def :=(v: T): Unit = {
    value = v
    pushSource.reactAll(v, null)
  }

  /** Same as `:=`. */
  def react(x: T) = this := x

  def react(x: T, hint: Any) = react(x)

  /** Propagates the exception to all the reactors.
   */
  def except(t: Throwable) = pushSource.exceptAll(t)

  /** Does nothing -- a cell never unreacts.
   */
  def unreact() {}

{'fraction_non_alphanumeric': 0.11640414905877833, 'fraction_numerical': 0.0, 'mean_word_length': 2.7848837209302326, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6434744', 'n_tokens_mistral': 860, 'n_tokens_neox': 806, 'n_words': 305}