<commit_before>package orc.run.tojava

import java.util.function.Consumer
import java.util.function.Function
import orc.OrcRuntime
import orc.Schedulable
import orc.OrcEvent
import orc.Handle
import orc.error.OrcException
import scala.util.parsing.input.Position
import java.util.concurrent.atomic.AtomicInteger
import orc.run.Logger

abstract class Context {
  import Context._
  
  val runtime: OrcRuntime
  
  def publish(v: AnyRef): Unit
  def halt(): Unit

  def spawn(f: Consumer[Context]): Unit = {
    prepareSpawn()
    runtime.schedule(() => f.accept(this))
  }
  
  def spawnFuture(f: Consumer[Context]): Future = {
    prepareSpawn()
    val fut = new Future(runtime)
    runtime.schedule { () =>
      f.accept(new ContextBase(this) {
        override def publish(v: AnyRef): Unit = {
          fut.bind(v)
        }
      })
    }
    fut
  }
  
  /** Setup for a spawn, but don't actually spawn anything.
   *  
   *  This is used in Future and possibly other places to prepare for a later execution.
   * 
   */
  def prepareSpawn(): Unit
  
  def checkKilled(): Unit = {
    if(! isLive()) {
      throw KilledException.SINGLETON
    }
  }
  def isLive(): Boolean
}

/**
 * @author amp
 */
class ContextBase(val parent: Context) extends Context {
  import Context._
  
  val runtime: OrcRuntime = parent.runtime
  
  def publish(v: AnyRef): Unit = {<commit_msg>Rename checkKilled to checkLive.<commit_after>package orc.run.tojava

import java.util.function.Consumer
import java.util.function.Function
import orc.OrcRuntime
import orc.Schedulable
import orc.OrcEvent
import orc.Handle
import orc.error.OrcException
import scala.util.parsing.input.Position
import java.util.concurrent.atomic.AtomicInteger
import orc.run.Logger

abstract class Context {
  import Context._
  
  val runtime: OrcRuntime
  
  def publish(v: AnyRef): Unit
  def halt(): Unit

  def spawn(f: Consumer[Context]): Unit = {
    prepareSpawn()
    runtime.schedule(() => f.accept(this))
  }
  
  def spawnFuture(f: Consumer[Context]): Future = {
    prepareSpawn()
    val fut = new Future(runtime)
    runtime.schedule { () =>
      f.accept(new ContextBase(this) {
        override def publish(v: AnyRef): Unit = {
          fut.bind(v)
        }
      })
    }
    fut
  }
  
  /** Setup for a spawn, but don't actually spawn anything.
   *  
   *  This is used in Future and possibly other places to prepare for a later execution.
   * 
   */
  def prepareSpawn(): Unit
  
  def checkLive(): Unit = {
    if(! isLive()) {
      throw KilledException.SINGLETON
    }
  }
  def isLive(): Boolean
}

/**
 * @author amp
 */
class ContextBase(val parent: Context) extends Context {
  import Context._
  
  val runtime: OrcRuntime = parent.runtime
  
  def publish(v: AnyRef): Unit = {
{'fraction_non_alphanumeric': 0.10854670032455824, 'fraction_numerical': 0.0, 'mean_word_length': 2.9685264663805437, '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': '2353720', 'n_tokens_mistral': 887, 'n_tokens_neox': 882, 'n_words': 239}