Sha256: ba11e7d51a229e48b1ae27713cd72a16ec61ca4f1fa5c31fdedce3dfc7cd89a4

Contents?: true

Size: 537 Bytes

Versions: 1

Compression:

Stored size: 537 Bytes

Contents

# Does the same as actors_primitive.fy but using
# normal objects as actors by sending messages asynchronously (via @@ syntax).
class PingPong {
  Done = false
  def initialize: @block {
  }

  def count: count reply: other {
    @block call
    if: (count > 1000) then: {
      count println
      Done = true
    } else: {
      other @@ count: (count + 1) reply: self
    }
  }
}

pong = PingPong new: { "-" print }
ping = PingPong new: { "." print }

ping @@ count: 1 reply: pong

until: { PingPong Done } do: {
  Thread sleep: 0.1
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fancy-0.4.0 examples/actors.fy