Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Lauwens BenLauwens

  • Royal Military Academy
  • Brussels
View GitHub Profile
View postoffice.jl
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
View closures.jl
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 Jan 27, 2017
Playing with intertask communication in Julia
View intertask.jl
workspace()
function fibonnaci_yieldto(super::Task)
a = 0.0
b = 1.0
while true
yieldto(super, a)
a, b = b, a + b
end
end