gen_server2 in Elixir application

59 views
Skip to first unread message

Santiago Fernandez

unread,
Jul 25, 2016, 9:11:32 AM7/25/16
to elixir-l...@googlegroups.com
Hi,

Is it possible to add gen_server2 [1] behaviour to a Elixir app? (`use GenServer2` instead `use GenServer`)
I'd like to prioritize incoming messages and set timeouts previous to process hibernation.


Thanks!

--
Santiago

OvermindDL1

unread,
Jul 25, 2016, 10:03:46 AM7/25/16
to elixir-lang-talk
Except in this case instead of `use` it would be `@behaviour gen_server2`, but yes you can.

Peter Hamilton

unread,
Jul 25, 2016, 10:06:13 AM7/25/16
to elixir-lang-talk

It's important to understand that `use GenServer` is not directly related to the behavior. It is a macro that calls GenServer.__using__ which happens to add @behaviour :gen_server to the current module as well as define default implementations for the callbacks.

For :gen_server2, you just have to do all that yourself. Otherwise it should work fine.


--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/7abdaf00-7021-4ddc-9b9e-6f3710b4bb19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages