Skip to content
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

Merged
merged 4 commits into from
Dec 5, 2024

Conversation

karlsson
Copy link
Contributor

@karlsson karlsson commented Dec 4, 2024

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.

Copy link
Member

@lpil lpil left a 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!

Nil
}
@external(erlang, "gleam_erlang_ffi", "send")
pub fn send(subject: Subject(message), message: message) -> Nil
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Member

@lpil lpil Dec 4, 2024

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.

Copy link
Contributor Author

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.

@karlsson karlsson marked this pull request as ready for review December 4, 2024 14:03
@karlsson
Copy link
Contributor Author

karlsson commented Dec 4, 2024

Ok, I think I missed some proper documentation for receive_forever..... 😄

Copy link
Member

@lpil lpil left a 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

@lpil lpil merged commit cba54bd into gleam-lang:main Dec 5, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants