From 456fd1364ad983de93dc5abf3c4d91b1683de69e Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Sun, 28 Jan 2018 09:47:46 -0800 Subject: [PATCH] add handle method to contexts --- src/context.rs | 7 +++++++ src/ws/context.rs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/context.rs b/src/context.rs index 1702c8c32..614184d1d 100644 --- a/src/context.rs +++ b/src/context.rs @@ -167,6 +167,13 @@ impl HttpContext where A: Actor { } self.stream.as_mut().map(|s| s.push(frame)); } + + /// Handle of the running future + /// + /// SpawnHandle is the handle returned by `AsyncContext::spawn()` method. + pub fn handle(&self) -> SpawnHandle { + self.inner.curr_handle() + } } impl ActorHttpContext for HttpContext where A: Actor, S: 'static { diff --git a/src/ws/context.rs b/src/ws/context.rs index 001b90185..6c0598b7e 100644 --- a/src/ws/context.rs +++ b/src/ws/context.rs @@ -191,6 +191,13 @@ impl WebsocketContext where A: Actor { } self.stream.as_mut().map(|s| s.push(frame)); } + + /// Handle of the running future + /// + /// SpawnHandle is the handle returned by `AsyncContext::spawn()` method. + pub fn handle(&self) -> SpawnHandle { + self.inner.curr_handle() + } } impl ActorHttpContext for WebsocketContext where A: Actor, S: 'static {