OvermindDL1

OvermindDL1

Not inside, rather for interacting with from outside, so you can submit a request to a genserver, do other work, then get the result, it’s the standard segregated send/receive set just in function form. :slight_smile:

0
Post #12
peerreynders

peerreynders

Which Task.async/1, Task.await/2 already gives you - you just want to get rid of the extraneous process.

0
Post #13
OvermindDL1

OvermindDL1

Yeah that would be odd to spool up a new process just to perform a call that the ‘call’ is already doing.

A GenServer.call is already doing what I proposed anyway:
https://github.com/elixir-lang/elixir/blob/v1.6.6/lib/elixir/lib/gen_server.ex#L823-L841
Which calls:
https://github.com/erlang/otp/blob/master/lib/stdlib/src/gen.erl#L152-L182

I’m just proposing splitting it up so instead of performing the call and then receive-waiting for the response, it just breaks up those two steps. You can do that manually in the GenServer itself, but I’m not sure that actually belongs in the GenServer, it is the caller side that knows whether they want it all done in one call or an async/await after all, and it would just transparently work with gen_call’s regardless with no change to the server code at all.

0
Post #14
jeremyjh

jeremyjh

This makes sense to me - when you invoke call the client process monitors the GenServer. If the GenServer crashes or you lose connection the client process will get an exit as well. We’d want the same behavior on await, and its these little details that people would often miss if they implement this on their own.

2
Post #15
OvermindDL1

OvermindDL1

Indeed! :slight_smile:

0
Post #16
— All posts loaded —