Module: GenServer
- Defined in:
- lib/gen_server.rb
Class Method Summary collapse
- .call(pid, method, *args) ⇒ Object
- .cast(pid, method, *args) ⇒ Object
- .start_link(mod, *args) ⇒ Object
- .terminate(pid) ⇒ Object
Class Method Details
.call(pid, method, *args) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/gen_server.rb', line 6 def call(pid, method, *args) entry = fetch_entry(pid) value, state = entry.module.send(method, entry.state, *args) entry.state = state update_entry(pid, entry) value end |
.cast(pid, method, *args) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/gen_server.rb', line 14 def cast(pid, method, *args) entry = fetch_entry(pid) entry.state = entry.module.send(method, entry.state, *args) update_entry(pid, entry) nil end |
.start_link(mod, *args) ⇒ Object
21 22 23 24 |
# File 'lib/gen_server.rb', line 21 def start_link(mod, *args) state = mod.init(*args) add_entry(mod, state) end |
.terminate(pid) ⇒ Object
26 27 28 |
# File 'lib/gen_server.rb', line 26 def terminate(pid) remove_entry(pid) end |