Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Build in conditional check for multicall, abcast.
  • Loading branch information
Qqwy committed Jun 10, 2017
commit e0f648916939cc358e541637a096c25799230611
25 changes: 15 additions & 10 deletions lib/exactor/operations.ex
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@ defmodule ExActor.Operations do
server_fun: server_fun(type),
interface_args: Macro.escape(interface_args(interface_matches, options), unquote: true),
gen_server_args: Macro.escape(gen_server_args(options, type, payload), unquote: true),
guard: Macro.escape(guard(options, :interface), unquote: true)
# export_option?: Keyword.get(options, :export, nil)
guard: Macro.escape(guard(options, :interface), unquote: true),
export_option: Macro.escape(options[:export], unquote: true)
] do
{interface_args, gen_server_args} =
unless type in [:multicall, :abcast] do
Expand All @@ -583,17 +583,22 @@ defmodule ExActor.Operations do
}
end

# Extract the server reference as first argument,
# And call `server_pid/1` on it inside the interface implementation.
# (But not in the function head)
[server_ref | gen_server_args_tail] = gen_server_args
server_pid_quote = quote(do: server_pid(unquote(server_ref)))
interface_gen_server_args = [server_pid_quote | gen_server_args_tail]
interface_gen_server_args =
if type in [:multicall, :abcast] || export_option do
gen_server_args
else
# Extract the server reference as first argument,
# And call `server_pid/1` on it inside the interface implementation.
# (But not in the function head)
[server_ref | gen_server_args_tail] = gen_server_args
server_pid_quote = quote(do: server_pid(unquote(server_ref)))
[server_pid_quote | gen_server_args_tail]
end

interface_body =
quote do
GenServer.unquote(server_fun)(unquote_splicing(interface_gen_server_args))
end
GenServer.unquote(server_fun)(unquote_splicing(interface_gen_server_args))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line and the next one need to be indented once more.

end

cond do
private == nil && guard == nil ->
Expand Down
1 change: 0 additions & 1 deletion lib/exactor/tolerant.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ defmodule ExActor.Tolerant do
import ExActor.Responders

unquote(ExActor.Helper.init_generation_state(opts))

end
end
end