<commit_before>require 'thread'

require 'concurrent/obligation'
require 'concurrent/observable'

module Concurrent

  # An `IVar` is a single-element container that is normally created empty, and
  # can only be set once. The I in `IVar` stands for immutable. Reading an `IVar`
  # normally blocks until it is set. It is safe to set and read an `IVar` from
  # different threads.
  #
  # If you want to have some parallel task set the value in an `IVar`, you want
  # a `Future`. If you want to create a graph of parallel tasks all executed when
  # the values they depend on are ready you want `dataflow`. `IVar` is generally
  # a low-level primitive.
  #
  # @example Create, set and get an `IVar`
  # ivar = Concurrent::IVar.new
  # ivar.set 14
  # ivar.get #=> 14
  # ivar.set 2 # would now be an error
  class IVar

    # Error that indicates that an `IVar` was set twice. Each `IVar` can only
    # be set once - they are immutable.
    MultipleAssignmentError = Class.new(StandardError)

    include Obligation
    include Observable

    # @!visibility private
    NO_VALUE = Object.new # :nodoc:

    # Create a new `IVar` in the `:pending` state with the (optional) initial value.
    #
    # @param [Object] value the initial value
    # @param [Hash] opts the options to create a message with
    # @option opts [String] :dup_on_deref (false) call `#dup` before returning the data
    # @option opts [String] :freeze_on_deref (false) call `#freeze` before returning the data
    # @option opts [String] :copy_on_deref (nil) call the given `Proc` passing the internal value and
    #   returning the value returned from the proc
    def initialize(value = NO_VALUE, opts = {})
      init_obligation
      self.observers = CopyOnWriteObserverSet.new
      set_deref_options(opts)<commit_msg>IVar: fix example markup.<commit_after>require 'thread'

require 'concurrent/obligation'
require 'concurrent/observable'

module Concurrent

  # An `IVar` is a single-element container that is normally created empty, and
  # can only be set once. The I in `IVar` stands for immutable. Reading an `IVar`
  # normally blocks until it is set. It is safe to set and read an `IVar` from
  # different threads.
  #
  # If you want to have some parallel task set the value in an `IVar`, you want
  # a `Future`. If you want to create a graph of parallel tasks all executed when
  # the values they depend on are ready you want `dataflow`. `IVar` is generally
  # a low-level primitive.
  #
  # @example Create, set and get an `IVar`
  #   ivar = Concurrent::IVar.new
  #   ivar.set 14
  #   ivar.get #=> 14
  #   ivar.set 2 # would now be an error
  class IVar

    # Error that indicates that an `IVar` was set twice. Each `IVar` can only
    # be set once - they are immutable.
    MultipleAssignmentError = Class.new(StandardError)

    include Obligation
    include Observable

    # @!visibility private
    NO_VALUE = Object.new # :nodoc:

    # Create a new `IVar` in the `:pending` state with the (optional) initial value.
    #
    # @param [Object] value the initial value
    # @param [Hash] opts the options to create a message with
    # @option opts [String] :dup_on_deref (false) call `#dup` before returning the data
    # @option opts [String] :freeze_on_deref (false) call `#freeze` before returning the data
    # @option opts [String] :copy_on_deref (nil) call the given `Proc` passing the internal value and
    #   returning the value returned from the proc
    def initialize(value = NO_VALUE, opts = {})
      init_obligation
      self.observers = CopyOnWriteObserverSet.new
      set_deref_options(opts)
{'fraction_non_alphanumeric': 0.0827357970215113, 'fraction_numerical': 0.0027578599007170436, 'mean_word_length': 3.3127229488703924, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '4786198', 'n_tokens_mistral': 1115, 'n_tokens_neox': 1088, 'n_words': 466}