29 lines
632 B
Elixir
29 lines
632 B
Elixir
defmodule Scopes.CSys do
|
|
require Logger
|
|
|
|
alias Scopes.Core.Actor
|
|
|
|
def neuron(scope) do
|
|
Logger.info([scope: inspect(scope)])
|
|
Actor.create(fn msg -> process(msg, scope) end)
|
|
end
|
|
|
|
def update_neuron(scope) do
|
|
Actor.become(self(), fn msg -> process(msg, scope) end)
|
|
end
|
|
|
|
def synapse(rcvr, op, delay \\ 0) do
|
|
fn msg -> Actor.send(rcvr, op.(msg), delay) end
|
|
end
|
|
|
|
# helper functions
|
|
|
|
defp process(msg, scope) do
|
|
proc(scope).(msg, scope)
|
|
end
|
|
|
|
def state(scope), do: elem(scope, 0)
|
|
def proc(scope), do: elem(scope, 1)
|
|
def syns(scope), do: elem(scope, 2)
|
|
def env(scope), do: elem(scope, 3)
|
|
end
|