-
Notifications
You must be signed in to change notification settings - Fork 2.6k
RpcHandlers Refactorings #6846
RpcHandlers Refactorings #6846
Changes from all commits
529dac2
2c19950
3da0cef
23e5640
901754e
94c525c
641d9b9
c43f762
1439bba
5f61b4f
172ccdd
70325ee
4b54972
3f83364
bce71e9
8bd60aa
b8f42a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -336,9 +336,12 @@ impl TaskManager { | |
} | ||
} | ||
|
||
/// Set what the task manager should keep alive. | ||
pub(super) fn keep_alive<T: 'static + Send + Sync>(&mut self, to_keep_alive: T) { | ||
self.keep_alive = Box::new(to_keep_alive); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @expenses I was sure that you did make a tuple magic thingy here that would make this function callable multiple times 🤔 why was is it gone? I'm missing something... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I totally mean S0mething, else, yolo. I think she refactored her code before pushing and since keep_alive here is privat-ish she didn't foresee it could be misused. Clearly something to fix, it's a pitfall. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah SOmething :P You should change your font to distinguish O and 0 :P There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The mix between the monospace font and sans font tricked my eyes |
||
/// Set what the task manager should keep alive, can be called multiple times. | ||
pub fn keep_alive<T: 'static + Send + Sync>(&mut self, to_keep_alive: T) { | ||
// allows this fn to safely called multiple times. | ||
use std::mem; | ||
let old = mem::replace(&mut self.keep_alive, Box::new(())); | ||
self.keep_alive = Box::new((to_keep_alive, old)); | ||
Comment on lines
-339
to
+344
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you absolutely need to call this function more than once, then this is fine.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's just to tempting to call it more than once imo. If there is no downside we should do it |
||
} | ||
|
||
/// Register another TaskManager to terminate and gracefully shutdown when the parent | ||
|
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.
Do you absolutely need this function, or can you add the
MetaIoHandler
methods directly toRpcHandlers
? If so, that would be cleaner and more abstract IMO.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 so the use case for this is to allow end users (and me 😇 ) use the
jsonrpc-core-client
local transport, which takes aDeref<Target=MetaIoHandler> + 'static
. Hence the need to have theMetaIoHandler
behind anArc
.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, fair enough : )