Ref cells in gleam:
Repo
https://github.com/Robert4S/gleam_ref
Docs:
https://hexdocs.pm/ref/
1 messages · Page 1 of 1 (latest)
Ref cells in gleam:
Repo
https://github.com/Robert4S/gleam_ref
Docs:
https://hexdocs.pm/ref/
Nice! You probably also want a way to shut the actor down as otherwise it'll live forever and you'll leak memory
get also says it can never fail- but in reality it can as the actor might be dead
Not sure if that matters though
Probably also want a way to get the Pid too so you can supervise it
Check out Elixir's Actor if you haven't
Yeah I was thinking about that, and was wondering if the runtime shuts down an actor if the GC cleaned up it's handle, but considering this may be a bit outside the normal use case for actors I'm assuming not.
Actors can do things all by themselves and there's no global garbage collection in Erlang so there's no real way the runtime could tell if you're finished with one
And there's ways to get a reference to one after other references have been lost
oops, typo, this should say "Agent"
alright so I gotta make get return a result then if i'm adding a way to shut down the actor
You could keep it not return a result if you like
But documenting that it panics if the actor is shutdown could be good
would there be any way for it to shut down other than a panic in the function passed to it if I don't provide a shutdown function in the API?
What do you mean, sorry?
if I do not provide a way to shut down the actor in the API, is there any other way for it to shut down
other than a panic in the function that the actor calls with the Set message
You could find the process id through VM debugging and monitoring tools and then manually kill it
Not sure what you mean by this.
get can fail if the actor is dead. can the actor become dead if there is no explicit way to kill it?