-
Notifications
You must be signed in to change notification settings - Fork 674
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
Add SigSet::union and SigSet::clear. #347
Conversation
The man page for
So should these functions really need to return a |
http://linux.die.net/man/3/sigaddset disagrees. Which platform are you using? |
Ah, ignore my comment. It seems that the OSX versions don't ever return an error according to the man pages on my system (OSX 10.11). |
Any other critique? Or can we merge this? |
for i in 1..NSIG { | ||
if try!(other.contains(i)) { | ||
try!(self.add(i)); | ||
} |
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'm surprised this is a loop! I don't know if we want what looks like 1-2 bitwise operations to actually end up being ~50-100. My feeling is that at this level, small code should have small cost.
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.
You would think! But even as a user of libc we should be unaware of the implementation details of sigaddset etc.
Oh interesting re errors. If / when we move to a I have one comment about unexpected number of operations from |
@fiveop I assume these came out of your need. Could you say a tiny bit about where |
Regarding the errors that is correct. I wonder what OS X does, if you pass it an invalid signal value. These kind of functions are exactly what I am looking for in nix. I don't want them in my application or library. Regarding the usecase. Suppose I have a base mask that I always want to block. Then I have depending on the situation various sets that I want to block in addition. As an example look at: https://github.com/sbcl/sbcl/blob/master/src/runtime/interrupt.c#L233. Note that they implemented their own function sigcopyset as a memcpy. This is sort of safe, because you do not need to know anything about the internal structure of a sigset. However, a bitwise or for |
This makes sense to me. The only thing I wonder is if we should change We can always attempt to optimize it if we think it matters, and add some fancier testing. |
I changed the name. |
Not seeing the change. Could you also update the commit message and PR title when you do. Then r=me. |
In other Set/Map APIs in Rust |
How about going with add_set? |
I believe the idiomatic way to merge a HashSet into another HashSet is |
In that case we can go all the way and implement Iterator, IntoIterator and Extend for SigSet. I'll prepare corresponding change. |
I would wait for @kamalmarhubi's views. |
I was actually just coming here to suggest this. Being able to iterate over the The traits are all in core, so |
Sounds good @kamalmarhubi! |
Implementing I have changed the name to extend for now. |
This seems good to me since the name will be change. The return type would drop the Re enums, I started today on a |
Add SigSet::union and SigSet::clear.
☀️ Test successful - status |
No description provided.