Skip to content

Instantly share code, notes, and snippets.

View BenLauwens's full-sized avatar

Ben Lauwens BenLauwens

  • Royal Military Academy
  • Brussels
View GitHub Profile
using SimJulia, Distributions
@resumable function people(sim::Simulation, λ::Float64, clerk::Resource)
i = 1
while true
Δt = rand(Exponential(1/λ))
@yield return Timeout(sim, Δt)
@coroutine customer(sim, i, clerk)
i += 1
end
workspace()
function fibonnaci(a::Float64=0.0, b::Float64=1.0) :: Function
_state = 0x00
function fib(ret::Any = nothing) :: Float64
_state == 0x00 && @goto _STATE_0
_state == 0x01 && @goto _STATE_1
error("Iterator has stopped!")
@label _STATE_0
_state = 0xff
@BenLauwens
BenLauwens / intertask.jl
Created January 27, 2017 08:49
Playing with intertask communication in Julia
workspace()
function fibonnaci_yieldto(super::Task)
a = 0.0
b = 1.0
while true
yieldto(super, a)
a, b = b, a + b
end
end