Skip to content

Commit c7e0943

Browse files
committed
Merge pull request #1317 from bettio/fix-avmport
Fix `AVMPort` Fix AVMPort, and remove warning from HelloWorld.ex. These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents 1d331a4 + fcf9763 commit c7e0943

File tree

2 files changed

+3
-30
lines changed

2 files changed

+3
-30
lines changed

examples/elixir/HelloWorld.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ defmodule HelloWorld do
2525
def start() do
2626
Console.print("Hello World\n")
2727
Console.puts("Console.puts() and Console.print() work with binary ")
28-
Console.puts('or charlist strings.\n')
28+
Console.puts(~c"or charlist strings.\n")
2929
Console.flush()
3030
end
3131
end

libs/exavmlib/lib/AVMPort.ex

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,12 @@ defmodule AVMPort do
3131

3232
@spec call(pid(), term()) :: term()
3333
def call(pid, message) do
34-
case :erlang.is_process_alive(pid) do
35-
false ->
36-
{:error, :noproc}
37-
38-
true ->
39-
ref = :erlang.make_ref()
40-
send(pid, {self(), ref, message})
41-
42-
receive do
43-
:out_of_memory -> :out_of_memory
44-
{^ref, reply} -> reply
45-
end
46-
end
34+
:port.call(pid, message)
4735
end
4836

4937
@spec call(pid(), term(), non_neg_integer()) :: term()
5038
def call(pid, message, timeoutMs) do
51-
case :erlang.is_process_alive(pid) do
52-
false ->
53-
{:error, :noproc}
54-
55-
true ->
56-
ref = :erlang.make_ref()
57-
send(pid, {self(), ref, message})
58-
59-
receive do
60-
:out_of_memory -> :out_of_memory
61-
{^ref, reply} -> reply
62-
after
63-
timeoutMs ->
64-
{:error, :timeout}
65-
end
66-
end
39+
:port.call(pid, message, timeoutMs)
6740
end
6841

6942
@spec open(term(), list()) :: pid()

0 commit comments

Comments
 (0)