Sha256: e6705b51fe1fd9a695eb3e86b726c5e2dfbfecfc543227ceead7b3e2779fba00

Contents?: true

Size: 669 Bytes

Versions: 6

Compression:

Stored size: 669 Bytes

Contents

class Ring {
  class Node {
    def initialize: @next ring: @ring

    def count: count {
      match @next {
        case nil ->
          "DONE: " ++ count println
          @ring finish!
        case _ ->
          "." print
          @next @@ count: (count + 1)
      }
      die! # let this actor die to free resources
    }
  }

  def initialize: amount {
    node = nil
    amount times: {
      node = Node new: node ring: self
    }
    @start = node
  }

  def start: @parent {
    @start count: 1
  }

  def finish! {
    @parent run
  }
}

# create ring and run through it
ring = Ring new: 4000
ring start: $ Thread current
Thread stop # wait until finished

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fancy-0.10.0 examples/actors_ring.fy
fancy-0.9.0 examples/actors_ring.fy
fancy-0.8.0 examples/actors_ring.fy
fancy-0.7.0 examples/actors_ring.fy
fancy-0.6.0 examples/actors_ring.fy
fancy-0.5.0 examples/actors_ring.fy