<commit_before>package examples

object oneplacebuffer {

  import scala.concurrent._;

  class OnePlaceBuffer {
    private val m = new MailBox() {}          // An internal mailbox
    private case class Empty()                // Types of messages we deal with
    private case class Full(x: Int)

    m send Empty()                            // Initialization

    def write(x: Int): Unit = m receive {
      case Empty() =>
        Console.println("put " + x)
        m send Full(x)
    }

    def read: Int = m receive {
      case Full(x) =>
        Console.println("get " + x)
        m send Empty(); x
    }
  }

  def main(args: Array[String]) = {
    val buf = new OnePlaceBuffer
    val random = new java.util.Random()

    def producer(n: int): unit = {
      Thread.sleep(random.nextInt(1000))
      buf.write(n)
      producer(n + 1)
    }

    def consumer: unit = {
      Thread.sleep(random.nextInt(1000))
      val n = buf.read
      consumer
    }

    ops.spawn(producer(0))
    ops.spawn(consumer)
  }

}
<commit_msg>added method 'kill' in docs/examples/oneplacebu...<commit_after>package examples

object oneplacebuffer {

  import scala.concurrent._;

  class OnePlaceBuffer {
    private val m = new MailBox() {}          // An internal mailbox
    private case class Empty()                // Types of messages we deal with
    private case class Full(x: Int)

    m send Empty()                            // Initialization

    def write(x: Int): Unit = m receive {
      case Empty() =>
        Console.println("put " + x)
        m send Full(x)
    }

    def read: Int = m receive {
      case Full(x) =>
        Console.println("get " + x)
        m send Empty(); x
    }
  }

  def main(args: Array[String]) = {
    val buf = new OnePlaceBuffer
    val random = new java.util.Random()

    def producer(n: int): unit = {
      Thread.sleep(random.nextInt(1000))
      buf.write(n)
      producer(n + 1)
    }

    def consumer: unit = {
      Thread.sleep(random.nextInt(1000))
      val n = buf.read
      consumer
    }

    def kill = new java.util.Timer().schedule(
      new java.util.TimerTask {
        override def run() = System.exit(0)
      },
      10000) // delay in milliseconds

    ops.spawn(producer(0))
    ops.spawn(consumer)
    kill
  }

}

{'fraction_non_alphanumeric': 0.11426079372001745, 'fraction_numerical': 0.0113388573920628, 'mean_word_length': 1.8928121059268601, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4313148', 'n_tokens_mistral': 741, 'n_tokens_neox': 690, 'n_words': 199}