-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify process.receive/send and add receive_forever function #68
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! This is great!
src/gleam/erlang/process.gleam
Outdated
Nil | ||
} | ||
@external(erlang, "gleam_erlang_ffi", "send") | ||
pub fn send(subject: Subject(message), message: message) -> Nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come this has changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just thought I would make it more simple. Instead of using raw_send which returns a DoNotLeak
I call own gleam_erlang_ffi:send
which pattern match the subject and returns nil
directly.
But maybe I missed something? Do you need DoNotLeak
if the erlang function returns nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having more code in Gleam and verified by Gleam is better! The DoNotLeak pattern is very useful and to be encouraged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will revert this back to original.
Ok, I think I missed some proper documentation for receive_forever..... 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely!! Thank you again
Remove the use of process.select function when calling process.receive.
Also added receive_forever.
I am not really sure this is not sub-optimizing, but added it as a result of a performance discussion on the gleam discord channel.