-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathc_node.ex
More file actions
39 lines (33 loc) · 711 Bytes
/
Copy pathc_node.ex
File metadata and controls
39 lines (33 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
defmodule Latency.CNode do
def echo() do
pid = open()
echo = &__MODULE__.echo(pid, &1)
close = fn() -> :ok end
{echo, close}
end
def echo(term) do
:latency_c_node.call(:echo, [term])
end
def echo(pid, term) do
:latency_c_node.call(pid, :echo, [term], :infinity)
end
def open() do
case :latency_c_node.get_pid() do
{:ok, pid} ->
pid
:error ->
case :latency_c_node.get_node() do
{:ok, node} ->
{:any, node}
:error ->
:erlang.error(:notsup)
end
end
end
def supported?() do
case :erlang.whereis(:latency_c_node) do
:undefined -> false
_ -> true
end
end
end