Created
January 29, 2016 15:12
-
-
Save binarytemple/f5f5a34699cdd15e8a6a to your computer and use it in GitHub Desktop.
Playing around with elixir processes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule TProcesses do | |
| def listener() do | |
| receive do | |
| {:hello} -> IO.puts "hello"; | |
| Other -> IO.puts "other" | |
| after | |
| 12_000 -> IO.puts "timeout" | |
| end | |
| listener() | |
| end | |
| end | |
| p = spawn(TProcesses,:listener, []) | |
| m = Process.monitor(p) | |
| receive do | |
| {:unexpected} -> :unexpected; | |
| after | |
| 20_000 -> Process.exit(p,:kill) | |
| end | |
| flush |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment