Advertisement
Guest User

linearizing.jl

a guest
Aug 19th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.38 KB | None | 0 0
  1. function linearWrapper(f::Function, proc::Channel)
  2.     take!(proc)
  3.     f()
  4.     put!(proc, 1)
  5. end
  6.  
  7. function f()
  8.     print("Running f\n")
  9. end
  10.  
  11. function g()
  12.     print("Running g\n")
  13. end
  14.  
  15. function h()
  16.     print("Running h\n")
  17. end
  18.  
  19. p = Channel(32)
  20.  
  21. put!(p, 1)
  22.  
  23. @async linearWrapper(f, p)
  24. @async linearWrapper(g, p)
  25. @async linearWrapper(h, p)
  26.  
  27. while true
  28.     yield()
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement