-
Notifications
You must be signed in to change notification settings - Fork 626
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
No way to represent a set of tasks #670
Comments
Does |
No, but looking at how it's implemented did. So thanks for that. I might leave this open though since any of my suggestions would have made this easier to solve. |
I’m not sure how providing a task set would help. I can’t really comment more without knowing what api you are trying to provide, but my initial impression is that using something like a TaskSet would result in a buggy impl. |
@carllerche It might result in some spurious wakeups if an object that needs to be notified keeps moving between different tasks. I think it would still be more efficient (in the general case) than the allocation and duplication involved in keeping tasks in a hash map and giving every object it's own key (aka what |
@CAndrew what happens if there are two clones being used on the same task and one drops? Would it not deregister all handles on that same task? |
@canndrew for the original question (something like hash/eq/ord for |
I'm going to close this as I don't think that there is anything to do. Please let me know if I am wrong. |
Came here for exactly the same question (hash, ord, or at least eq for tasks). Literally the first thing I saw after clicking on the "src" button for the Tasks should be opaque, but I don't see how a concrete implementation could look like that has no concept of equality. Even though the current implementation doesn't make it explicit (ie does not implement Eq), it still has to have some concept of checking whether two different tasks correspond to the same thing, right? And I can't imagine any implementation that truly does not rely on such a concept. So if every implementation needs this anyways, why not make it part of the API? Since you have spent a lot of time on the whole codebase, there's probably something I'm missing. So please don't read this as "I want Feature X!", but rather as "Someone is curious about the design of the library". I'd really appreciate if you could share some background on this. |
To clarify, the |
@AljoschaMeyer If there is a compelling reason to add |
I stumbled upon this while writing multi-producer sink. By taking ownership of a sink, you get a handle which you can clone, using an RC and a RefCell for interior mutability. The This can easily be done by assigning my own ids to the handle, but comparing Task equality is more elegant. And hopefully this is not heading towards buggyness, since I don't see how one could implement sink multiplexing without such an abstraction. Edit: The above description of the multiplexing assumes that |
The design that you are describing makes me think that you would hit the bug that I referenced above. If, for each Now, if you have two The solution to this problem is that you store an entry in your set for each |
I attempted to clarify the problem here: #689 |
Thank you, that clarified a lot! For other stumbling upon this while looking for stream/sink (de)multiplexing, here are my attempts: multi-producer-sink and multi-consumer-stream. |
I want to implement a future which can be cloned so that multiple tasks can be blocked waiting for the same external event. This doesn't seem to be possible to implement.
Task
doesn't implementHash
orEq
so I can't keep the set of pending tasks in aHashSet
or even aVec
because there's no way to de-duplicate the tasks. If someone keepspoll()
ing my future, or keeps cloning new ones, theVec
would grow indefinitely.Could we give
Task
an implementation ofHash
orOrd + Eq
or something? Alternatively, could we add aTaskSet
type for this use-case?The text was updated successfully, but these errors were encountered: