mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-25 00:00:18 +02:00
Limit the scope of borrow_mut in consume_queue
Otherwise we may accidentally hold the borrowed ref cell for too long which can cause a borrow error. Closes #190
This commit is contained in:
+21
-2
@@ -2,13 +2,14 @@ extern crate tokio_core;
|
||||
extern crate env_logger;
|
||||
extern crate futures;
|
||||
|
||||
use std::time::Duration;
|
||||
use std::sync::mpsc;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use futures::Future;
|
||||
use futures::future;
|
||||
use futures::sync::oneshot;
|
||||
use tokio_core::reactor::Core;
|
||||
use tokio_core::reactor::{Core, Timeout};
|
||||
|
||||
#[test]
|
||||
fn simple() {
|
||||
@@ -76,3 +77,21 @@ fn spawn_in_poll() {
|
||||
|
||||
assert_eq!(lp.run(rx1.join(rx2)).unwrap(), (1, 2));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn drop_timeout_in_spawn() {
|
||||
drop(env_logger::init());
|
||||
let mut lp = Core::new().unwrap();
|
||||
|
||||
let (tx, rx) = oneshot::channel();
|
||||
let remote = lp.remote();
|
||||
thread::spawn(move || {
|
||||
remote.spawn(|handle| {
|
||||
drop(Timeout::new(Duration::new(1, 0), handle));
|
||||
tx.send(()).unwrap();
|
||||
Ok(())
|
||||
});
|
||||
});
|
||||
|
||||
lp.run(rx).unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user