Conversation
mcobzarenco
left a comment
There was a problem hiding this comment.
Just my thoughts - High level, I would really love to see an explanation in the docs as to why you'd want to box your commands, also honest question as I didn't know why / when this is useful
|
Came back to look at this, fixed the fmt, think this could open up multithreaded command submissions. |
alice-i-cecile
left a comment
There was a problem hiding this comment.
Approved, but I want to see what the other folks working in this space have to think about it.
|
@jamescarterbell can you resolve the comments that are addressed to make this easier for the reviewers? Also clippy is failing :) |
Co-authored-by: Marius Cobzarenco <marius.cobzarenco@gmail.com>
Co-authored-by: Marius Cobzarenco <marius.cobzarenco@gmail.com>
hymm
left a comment
There was a problem hiding this comment.
I suspect for the parallel use case that #4749 probably avoids contention better than using a channel. (I haven't done any benching, so I wouldn't trust my guess too much.) Even if that is true, I expect that there are other use cases for boxable commands. If the linked PR gets merged we should maybe come up with another example for boxable commands in the docs.
|
I'm happy to merge this once the typos are fixed then. Thanks for the informed opinion @hymm. |
Co-authored-by: Mike <mike.hsu@gmail.com>
Yeah I made this before knowing about that PR... Maybe some sort of example with commands in events? Hmm... |
|
Yeah 🤔 I think I'd like to try and find another example for now to make this clearer; I want to get this + #4749 in for the next release and having a clear differentiation would be good. |
|
Personally I'm not a very big fan of this PR, considering that a |
|
@jamescarterbell, my personal feeling is that we should close this out until we have a compelling use case. |
|
Go for it |
Objective
Create a simple method of adding boxed commands to Commands. The cleanest method of adding Box currently isn't possible (adding Box directly), but we can do something close.
The end goal is to allow a performant method of adding commands to the CommandQueue across threads (mainly for sharing some form of Commands in a par_for_each loop).
Solution
By essentially creating and storing the CommandMetas write function alongside the Box in a specialized type, we can copy the data from the box into the CommandQueue, and move it's write function into the new CommandMeta object.