(index<- ) ./librustuv/lib.rs
git branch: * master 5200215 auto merge of #14035 : alexcrichton/rust/experimental, r=huonw
modified: Fri May 9 13:02:28 2014
1 // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 /*!
12
13 Bindings to libuv, along with the default implementation of `std::rt::rtio`.
14
15 UV types consist of the event loop (Loop), Watchers, Requests and
16 Callbacks.
17
18 Watchers and Requests encapsulate pointers to uv *handles*, which have
19 subtyping relationships with each other. This subtyping is reflected
20 in the bindings with explicit or implicit coercions. For example, an
21 upcast from TcpWatcher to StreamWatcher is done with
22 `tcp_watcher.as_stream()`. In other cases a callback on a specific
23 type of watcher will be passed a watcher of a supertype.
24
25 Currently all use of Request types (connect/write requests) are
26 encapsulated in the bindings and don't need to be dealt with by the
27 caller.
28
29 # Safety note
30
31 Due to the complex lifecycle of uv handles, as well as compiler bugs,
32 this module is not memory safe and requires explicit memory management,
33 via `close` and `delete` methods.
34
35 */
36
37 #![crate_id = "rustuv#0.11-pre"]
38 #![license = "MIT/ASL2"]
39 #![crate_type = "rlib"]
40 #![crate_type = "dylib"]
41
42 #![feature(macro_rules)]
43 #![deny(unused_result, unused_must_use)]
44 #![allow(visible_private_types)]
45
46 #[cfg(test)] extern crate green;
47 #[cfg(test)] extern crate realrustuv = "rustuv";
48 extern crate libc;
49
50 use libc::{c_int, c_void};
51 use std::cast;
52 use std::fmt;
53 use std::io::IoError;
54 use std::io;
55 use std::ptr::null;
56 use std::ptr;
57 use std::rt::local::Local;
58 use std::rt::rtio;
59 use std::rt::task::{BlockedTask, Task};
60 use std::str::raw::from_c_str;
61 use std::str;
62 use std::task;
63
64 pub use self::async::AsyncWatcher;
65 pub use self::file::{FsRequest, FileWatcher};
66 pub use self::idle::IdleWatcher;
67 pub use self::net::{TcpWatcher, TcpListener, TcpAcceptor, UdpWatcher};
68 pub use self::pipe::{PipeWatcher, PipeListener, PipeAcceptor};
69 pub use self::process::Process;
70 pub use self::signal::SignalWatcher;
71 pub use self::timer::TimerWatcher;
72 pub use self::tty::TtyWatcher;
73
74 // Run tests with libgreen instead of libnative.
75 //
76 // FIXME: This egregiously hacks around starting the test runner in a different
77 // threading mode than the default by reaching into the auto-generated
78 // '__test' module.
79 #[cfg(test)] #[start]
80 fn start(argc: int, argv: **u8) -> int {
81 green::start(argc, argv, event_loop, __test::main)
82 }
83
84 mod macros;
85
86 mod access;
87 mod timeout;
88 mod homing;
89 mod queue;
90 mod rc;
91
92 pub mod uvio;
93 pub mod uvll;
94
95 pub mod file;
96 pub mod net;
97 pub mod idle;
98 pub mod timer;
99 pub mod async;
100 pub mod addrinfo;
101 pub mod process;
102 pub mod pipe;
103 pub mod tty;
104 pub mod signal;
105 pub mod stream;
106
107 /// Creates a new event loop which is powered by libuv
108 ///
109 /// This function is used in tandem with libgreen's `PoolConfig` type as a value
110 /// for the `event_loop_factory` field. Using this function as the event loop
111 /// factory will power programs with libuv and enable green threading.
112 ///
113 /// # Example
114 ///
115 /// ```
116 /// extern crate rustuv;
117 /// extern crate green;
118 ///
119 /// #[start]
120 /// fn start(argc: int, argv: **u8) -> int {
121 /// green::start(argc, argv, rustuv::event_loop, main)
122 /// }
123 ///
124 /// fn main() {
125 /// // this code is running inside of a green task powered by libuv
126 /// }
127 /// ```
128 pub fn event_loop() -> Box<rtio::EventLoop:Send> {
129 box uvio::UvEventLoop::new() as Box<rtio::EventLoop:Send>
130 }
131
132 /// A type that wraps a uv handle
133 pub trait UvHandle<T> {
134 fn uv_handle(&self) -> *T;
135
136 fn uv_loop(&self) -> Loop {
137 Loop::wrap(unsafe { uvll::get_loop_for_uv_handle(self.uv_handle()) })
138 }
139
140 // FIXME(#8888) dummy self
141 fn alloc(_: Option<Self>, ty: uvll::uv_handle_type) -> *T {
142 unsafe {
143 let handle = uvll::malloc_handle(ty);
144 assert!(!handle.is_null());
145 handle as *T
146 }
147 }
148
149 unsafe fn from_uv_handle<'a>(h: &'a *T) -> &'a mut Self {
150 cast::transmute(uvll::get_data_for_uv_handle(*h))
151 }
152
153 fn install(~self) -> Box<Self> {
154 unsafe {
155 let myptr = cast::transmute::<&Box<Self>, &*u8>(&self);
156 uvll::set_data_for_uv_handle(self.uv_handle(), *myptr);
157 }
158 self
159 }
160
161 fn close_async_(&mut self) {
162 // we used malloc to allocate all handles, so we must always have at
163 // least a callback to free all the handles we allocated.
164 extern fn close_cb(handle: *uvll::uv_handle_t) {
165 unsafe { uvll::free_handle(handle) }
166 }
167
168 unsafe {
169 uvll::set_data_for_uv_handle(self.uv_handle(), null::<()>());
170 uvll::uv_close(self.uv_handle() as *uvll::uv_handle_t, close_cb)
171 }
172 }
173
174 fn close(&mut self) {
175 let mut slot = None;
176
177 unsafe {
178 uvll::uv_close(self.uv_handle() as *uvll::uv_handle_t, close_cb);
179 uvll::set_data_for_uv_handle(self.uv_handle(), ptr::null::<()>());
180
181 wait_until_woken_after(&mut slot, &self.uv_loop(), || {
182 uvll::set_data_for_uv_handle(self.uv_handle(), &slot);
183 })
184 }
185
186 extern fn close_cb(handle: *uvll::uv_handle_t) {
187 unsafe {
188 let data = uvll::get_data_for_uv_handle(handle);
189 uvll::free_handle(handle);
190 if data == ptr::null() { return }
191 let slot: &mut Option<BlockedTask> = cast::transmute(data);
192 wakeup(slot);
193 }
194 }
195 }
196 }
197
198 pub struct ForbidSwitch {
199 msg: &'static str,
200 io: uint,
201 }
202
203 impl ForbidSwitch {
204 fn new(s: &'static str) -> ForbidSwitch {
205 ForbidSwitch {
206 msg: s,
207 io: homing::local_id(),
208 }
209 }
210 }
211
212 impl Drop for ForbidSwitch {
213 fn drop(&mut self) {
214 assert!(self.io == homing::local_id(),
215 "didnt want a scheduler switch: {}",
216 self.msg);
217 }
218 }
219
220 pub struct ForbidUnwind {
221 msg: &'static str,
222 failing_before: bool,
223 }
224
225 impl ForbidUnwind {
226 fn new(s: &'static str) -> ForbidUnwind {
227 ForbidUnwind {
228 msg: s, failing_before: task::failing(),
229 }
230 }
231 }
232
233 impl Drop for ForbidUnwind {
234 fn drop(&mut self) {
235 assert!(self.failing_before == task::failing(),
236 "didnt want an unwind during: {}", self.msg);
237 }
238 }
239
240 fn wait_until_woken_after(slot: *mut Option<BlockedTask>,
241 loop_: &Loop,
242 f: ||) {
243 let _f = ForbidUnwind::new("wait_until_woken_after");
244 unsafe {
245 assert!((*slot).is_none());
246 let task: Box<Task> = Local::take();
247 loop_.modify_blockers(1);
248 task.deschedule(1, |task| {
249 *slot = Some(task);
250 f();
251 Ok(())
252 });
253 loop_.modify_blockers(-1);
254 }
255 }
256
257 fn wakeup(slot: &mut Option<BlockedTask>) {
258 assert!(slot.is_some());
259 let _ = slot.take_unwrap().wake().map(|t| t.reawaken());
260 }
261
262 pub struct Request {
263 pub handle: *uvll::uv_req_t,
264 defused: bool,
265 }
266
267 impl Request {
268 pub fn new(ty: uvll::uv_req_type) -> Request {
269 unsafe {
270 let handle = uvll::malloc_req(ty);
271 uvll::set_data_for_req(handle, null::<()>());
272 Request::wrap(handle)
273 }
274 }
275
276 pub fn wrap(handle: *uvll::uv_req_t) -> Request {
277 Request { handle: handle, defused: false }
278 }
279
280 pub fn set_data<T>(&self, t: *T) {
281 unsafe { uvll::set_data_for_req(self.handle, t) }
282 }
283
284 pub unsafe fn get_data<T>(&self) -> &'static mut T {
285 let data = uvll::get_data_for_req(self.handle);
286 assert!(data != null());
287 cast::transmute(data)
288 }
289
290 // This function should be used when the request handle has been given to an
291 // underlying uv function, and the uv function has succeeded. This means
292 // that uv will at some point invoke the callback, and in the meantime we
293 // can't deallocate the handle because libuv could be using it.
294 //
295 // This is still a problem in blocking situations due to linked failure. In
296 // the connection callback the handle should be re-wrapped with the `wrap`
297 // function to ensure its destruction.
298 pub fn defuse(&mut self) {
299 self.defused = true;
300 }
301 }
302
303 impl Drop for Request {
304 fn drop(&mut self) {
305 if !self.defused {
306 unsafe { uvll::free_req(self.handle) }
307 }
308 }
309 }
310
311 /// FIXME: Loop(*handle) is buggy with destructors. Normal structs
312 /// with dtors may not be destructured, but tuple structs can,
313 /// but the results are not correct.
314 pub struct Loop {
315 handle: *uvll::uv_loop_t
316 }
317
318 impl Loop {
319 pub fn new() -> Loop {
320 let handle = unsafe { uvll::loop_new() };
321 assert!(handle.is_not_null());
322 unsafe { uvll::set_data_for_uv_loop(handle, 0 as *c_void) }
323 Loop::wrap(handle)
324 }
325
326 pub fn wrap(handle: *uvll::uv_loop_t) -> Loop { Loop { handle: handle } }
327
328 pub fn run(&mut self) {
329 assert_eq!(unsafe { uvll::uv_run(self.handle, uvll::RUN_DEFAULT) }, 0);
330 }
331
332 pub fn close(&mut self) {
333 unsafe { uvll::uv_loop_delete(self.handle) };
334 }
335
336 // The 'data' field of the uv_loop_t is used to count the number of tasks
337 // that are currently blocked waiting for I/O to complete.
338 fn modify_blockers(&self, amt: uint) {
339 unsafe {
340 let cur = uvll::get_data_for_uv_loop(self.handle) as uint;
341 uvll::set_data_for_uv_loop(self.handle, (cur + amt) as *c_void)
342 }
343 }
344
345 fn get_blockers(&self) -> uint {
346 unsafe { uvll::get_data_for_uv_loop(self.handle) as uint }
347 }
348 }
349
350 // FIXME: Need to define the error constants like EOF so they can be
351 // compared to the UvError type
352
353 pub struct UvError(c_int);
354
355 impl UvError {
356 pub fn name(&self) -> ~str {
357 unsafe {
358 let inner = match self { &UvError(a) => a };
359 let name_str = uvll::uv_err_name(inner);
360 assert!(name_str.is_not_null());
361 from_c_str(name_str)
362 }
363 }
364
365 pub fn desc(&self) -> ~str {
366 unsafe {
367 let inner = match self { &UvError(a) => a };
368 let desc_str = uvll::uv_strerror(inner);
369 assert!(desc_str.is_not_null());
370 from_c_str(desc_str)
371 }
372 }
373
374 pub fn is_eof(&self) -> bool {
375 let UvError(handle) = *self;
376 handle == uvll::EOF
377 }
378 }
379
380 impl fmt::Show for UvError {
381 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
382 write!(f.buf, "{}: {}", self.name(), self.desc())
383 }
384 }
385
386 #[test]
387 fn error_smoke_test() {
388 let err: UvError = UvError(uvll::EOF);
389 assert_eq!(err.to_str(), "EOF: end of file".to_owned());
390 }
391
392 pub fn uv_error_to_io_error(uverr: UvError) -> IoError {
393 unsafe {
394 // Importing error constants
395
396 // uv error descriptions are static
397 let UvError(errcode) = uverr;
398 let c_desc = uvll::uv_strerror(errcode);
399 let desc = str::raw::c_str_to_static_slice(c_desc);
400
401 let kind = match errcode {
402 uvll::UNKNOWN => io::OtherIoError,
403 uvll::OK => io::OtherIoError,
404 uvll::EOF => io::EndOfFile,
405 uvll::EACCES => io::PermissionDenied,
406 uvll::ECONNREFUSED => io::ConnectionRefused,
407 uvll::ECONNRESET => io::ConnectionReset,
408 uvll::ENOTCONN => io::NotConnected,
409 uvll::ENOENT => io::FileNotFound,
410 uvll::EPIPE => io::BrokenPipe,
411 uvll::ECONNABORTED => io::ConnectionAborted,
412 uvll::EADDRNOTAVAIL => io::ConnectionRefused,
413 uvll::ECANCELED => io::TimedOut,
414 err => {
415 uvdebug!("uverr.code {}", err as int);
416 // FIXME: Need to map remaining uv error types
417 io::OtherIoError
418 }
419 };
420
421 IoError {
422 kind: kind,
423 desc: desc,
424 detail: None
425 }
426 }
427 }
428
429 /// Given a uv error code, convert a callback status to a UvError
430 pub fn status_to_maybe_uv_error(status: c_int) -> Option<UvError> {
431 if status >= 0 {
432 None
433 } else {
434 Some(UvError(status))
435 }
436 }
437
438 pub fn status_to_io_result(status: c_int) -> Result<(), IoError> {
439 if status >= 0 {Ok(())} else {Err(uv_error_to_io_error(UvError(status)))}
440 }
441
442 /// The uv buffer type
443 pub type Buf = uvll::uv_buf_t;
444
445 pub fn empty_buf() -> Buf {
446 uvll::uv_buf_t {
447 base: null(),
448 len: 0,
449 }
450 }
451
452 /// Borrow a slice to a Buf
453 pub fn slice_to_uv_buf(v: &[u8]) -> Buf {
454 let data = v.as_ptr();
455 uvll::uv_buf_t { base: data, len: v.len() as uvll::uv_buf_len_t }
456 }
457
458 // This function is full of lies!
459 #[cfg(test)]
460 fn local_loop() -> &'static mut uvio::UvIoFactory {
461 unsafe {
462 cast::transmute({
463 let mut task = Local::borrow(None::<Task>);
464 let mut io = task.local_io().unwrap();
465 let (_vtable, uvio): (uint, &'static mut uvio::UvIoFactory) =
466 cast::transmute(io.get());
467 uvio
468 })
469 }
470 }
471
472 #[cfg(test)]
473 mod test {
474 use std::cast::transmute;
475 use std::unstable::run_in_bare_thread;
476
477 use super::{slice_to_uv_buf, Loop};
478
479 #[test]
480 fn test_slice_to_uv_buf() {
481 let slice = [0, .. 20];
482 let buf = slice_to_uv_buf(slice);
483
484 assert_eq!(buf.len, 20);
485
486 unsafe {
487 let base = transmute::<*u8, *mut u8>(buf.base);
488 (*base) = 1;
489 (*base.offset(1)) = 2;
490 }
491
492 assert!(slice[0] == 1);
493 assert!(slice[1] == 2);
494 }
495
496
497 #[test]
498 fn loop_smoke_test() {
499 run_in_bare_thread(proc() {
500 let mut loop_ = Loop::new();
501 loop_.run();
502 loop_.close();
503 });
504 }
505 }
librustuv/lib.rs:132:34-132:34 -trait- definition:
/// A type that wraps a uv handle
pub trait UvHandle<T> {
fn uv_handle(&self) -> *T;
references:- 16149: unsafe fn from_uv_handle<'a>(h: &'a *T) -> &'a mut Self {
150: cast::transmute(uvll::get_data_for_uv_handle(*h))
--
153: fn install(~self) -> Box<Self> {
154: unsafe {
155: let myptr = cast::transmute::<&Box<Self>, &*u8>(&self);
156: uvll::set_data_for_uv_handle(self.uv_handle(), *myptr);
librustuv/timeout.rs:
360: pub fn set_timeout<U, T: UvHandle<U> + HomingIO>(
361: &mut self, ms: u64, t: &mut T
librustuv/net.rs:
383: impl UvHandle<uvll::uv_tcp_t> for TcpListener {
384: fn uv_handle(&self) -> *uvll::uv_tcp_t { self.handle }
--
530: impl UvHandle<uvll::uv_udp_t> for UdpWatcher {
531: fn uv_handle(&self) -> *uvll::uv_udp_t { self.handle }
librustuv/idle.rs:
80: impl UvHandle<uvll::uv_idle_t> for IdleWatcher {
81: fn uv_handle(&self) -> *uvll::uv_idle_t { self.handle }
librustuv/timer.rs:
72: impl UvHandle<uvll::uv_timer_t> for TimerWatcher {
73: fn uv_handle(&self) -> *uvll::uv_timer_t { self.handle }
librustuv/async.rs:
49: impl UvHandle<uvll::uv_async_t> for AsyncWatcher {
50: fn uv_handle(&self) -> *uvll::uv_async_t { self.handle }
librustuv/process.rs:
207: impl UvHandle<uvll::uv_process_t> for Process {
208: fn uv_handle(&self) -> *uvll::uv_process_t { self.handle }
librustuv/pipe.rs:
272: impl UvHandle<uvll::uv_pipe_t> for PipeListener {
273: fn uv_handle(&self) -> *uvll::uv_pipe_t { self.pipe }
librustuv/tty.rs:
122: impl UvHandle<uvll::uv_tty_t> for TtyWatcher {
123: fn uv_handle(&self) -> *uvll::uv_tty_t { self.tty }
librustuv/signal.rs:
61: impl UvHandle<uvll::uv_signal_t> for SignalWatcher {
62: fn uv_handle(&self) -> *uvll::uv_signal_t { self.handle }
librustuv/net.rs:
337: impl UvHandle<uvll::uv_tcp_t> for TcpWatcher {
338: fn uv_handle(&self) -> *uvll::uv_tcp_t { self.stream.handle }
librustuv/lib.rs:197:1-197:1 -struct- definition:
pub struct ForbidSwitch {
msg: &'static str,
io: uint,
references:- 4204: fn new(s: &'static str) -> ForbidSwitch {
205: ForbidSwitch {
206: msg: s,
--
212: impl Drop for ForbidSwitch {
213: fn drop(&mut self) {
librustuv/lib.rs:352:1-352:1 -struct- definition:
pub struct UvError(c_int);
impl UvError {
pub fn name(&self) -> ~str {
references:- 39librustuv/timeout.rs:
librustuv/file.rs:
librustuv/net.rs:
librustuv/addrinfo.rs:
librustuv/process.rs:
librustuv/pipe.rs:
librustuv/tty.rs:
librustuv/signal.rs:
librustuv/stream.rs:
librustuv/file.rs:
librustuv/lib.rs:256:1-256:1 -fn- definition:
fn wakeup(slot: &mut Option<BlockedTask>) {
assert!(slot.is_some());
let _ = slot.take_unwrap().wake().map(|t| t.reawaken());
references:- 11191: let slot: &mut Option<BlockedTask> = cast::transmute(data);
192: wakeup(slot);
193: }
librustuv/timeout.rs:
272: cx.status = uvll::ECANCELED;
273: wakeup(&mut cx.task);
274: }
librustuv/file.rs:
345: };
346: wakeup(slot);
347: }
librustuv/net.rs:
607: cx.result = Some((nread, addr));
608: wakeup(&mut cx.task);
609: }
--
837: cx.status = status;
838: wakeup(&mut cx.slot);
839: }
librustuv/addrinfo.rs:
111: wakeup(&mut cx.slot);
112: }
librustuv/process.rs:
132: if p.to_wake.is_none() { return }
133: wakeup(&mut p.to_wake);
134: }
librustuv/stream.rs:
272: let stream: &mut StreamWatcher = unsafe { &mut *wcx.stream };
273: wakeup(&mut stream.blocked_writer);
274: } else {
librustuv/timeout.rs:
303: if cx.task.is_some() {
304: wakeup(&mut cx.task);
305: }
librustuv/lib.rs:437:1-437:1 -fn- definition:
pub fn status_to_io_result(status: c_int) -> Result<(), IoError> {
if status >= 0 {Ok(())} else {Err(uv_error_to_io_error(UvError(status)))}
}
references:- 15librustuv/net.rs:
690: let _m = self.fire_homing_missile();
691: status_to_io_result(unsafe {
692: multi.to_str().with_c_str(|m_addr| {
--
732: let _m = self.fire_homing_missile();
733: status_to_io_result(unsafe {
734: uvll::uv_udp_set_broadcast(self.handle,
--
740: let _m = self.fire_homing_missile();
741: status_to_io_result(unsafe {
742: uvll::uv_udp_set_broadcast(self.handle,
--
828: status_to_io_result(cx.status)
829: }
librustuv/lib.rs:261:1-261:1 -struct- definition:
pub struct Request {
pub handle: *uvll::uv_req_t,
defused: bool,
references:- 7276: pub fn wrap(handle: *uvll::uv_req_t) -> Request {
277: Request { handle: handle, defused: false }
278: }
librustuv/timeout.rs:
227: mut self, obj: T, timeout: Option<u64>, io: &mut UvIoFactory,
228: f: |&Request, &T, uvll::uv_connect_cb| -> c_int
229: ) -> Result<T, UvError> {
librustuv/stream.rs:
31: // defined in libuv, so we're foced to malloc this.
32: last_write_req: Option<Request>,
librustuv/lib.rs:
303: impl Drop for Request {
304: fn drop(&mut self) {
librustuv/lib.rs:452:28-452:28 -fn- definition:
/// Borrow a slice to a Buf
pub fn slice_to_uv_buf(v: &[u8]) -> Buf {
let data = v.as_ptr();
references:- 6librustuv/net.rs:
558: task: None,
559: buf: Some(slice_to_uv_buf(buf)),
560: result: None,
--
626: } else {
627: slice_to_uv_buf(buf)
628: };
librustuv/stream.rs:
76: let mut rcx = ReadContext {
77: buf: Some(slice_to_uv_buf(buf)),
78: // if the read is canceled, we'll see eof, otherwise this will get
--
160: let uv_buf = if may_timeout {
161: slice_to_uv_buf(data.get_ref().as_slice())
162: } else {
163: slice_to_uv_buf(buf)
164: };
librustuv/net.rs:
624: let uv_buf = if guard.can_timeout {
625: slice_to_uv_buf(data.get_ref().as_slice())
626: } else {
librustuv/lib.rs:313:37-313:37 -struct- definition:
/// but the results are not correct.
pub struct Loop {
handle: *uvll::uv_loop_t
references:- 36librustuv/timeout.rs:
librustuv/queue.rs:
librustuv/uvio.rs:
librustuv/file.rs:
librustuv/net.rs:
librustuv/idle.rs:
librustuv/timer.rs:
librustuv/async.rs:
librustuv/addrinfo.rs:
librustuv/pipe.rs:
librustuv/file.rs:
librustuv/lib.rs:239:1-239:1 -fn- definition:
fn wait_until_woken_after(slot: *mut Option<BlockedTask>,
loop_: &Loop,
f: ||) {
references:- 11181: wait_until_woken_after(&mut slot, &self.uv_loop(), || {
182: uvll::set_data_for_uv_handle(self.uv_handle(), &slot);
librustuv/timeout.rs:
242: }
243: wait_until_woken_after(&mut self.task, &io.loop_, || {
244: let data = &self as *_;
librustuv/file.rs:
330: let loop_ = unsafe { uvll::get_loop_from_fs_req(req.req) };
331: wait_until_woken_after(&mut slot, &Loop::wrap(loop_), || {
332: unsafe { uvll::set_data_for_req(req.req, &slot) }
librustuv/net.rs:
637: };
638: wait_until_woken_after(&mut self.blocked_sender, &loop_, || {
639: req.set_data(&cx);
--
824: wait_until_woken_after(&mut cx.slot, loop_, || {
825: req.set_data(&cx);
librustuv/timer.rs:
99: self.action = Some(WakeTask);
100: wait_until_woken_after(&mut self.blocker, &self.uv_loop(), || {
101: self.start(timer_cb, msecs, 0);
librustuv/addrinfo.rs:
89: wait_until_woken_after(&mut cx.slot, loop_, || {
90: req.set_data(&cx);
librustuv/stream.rs:
96: let loop_ = unsafe { uvll::get_loop_for_uv_handle(self.handle) };
97: wait_until_woken_after(&mut rcx.task, &Loop::wrap(loop_), || {});
98: match rcx.result {
--
180: let loop_ = unsafe { uvll::get_loop_for_uv_handle(self.handle) };
181: wait_until_woken_after(&mut self.blocked_writer,
182: &Loop::wrap(loop_), || {
librustuv/process.rs:
234: // need to deschedule ourselves and wait to be reawoken.
235: wait_until_woken_after(&mut self.to_wake, &self.uv_loop(), || {});
236: assert!(self.exit_status.is_some());
librustuv/lib.rs:219:1-219:1 -struct- definition:
pub struct ForbidUnwind {
msg: &'static str,
failing_before: bool,
references:- 4226: fn new(s: &'static str) -> ForbidUnwind {
227: ForbidUnwind {
228: msg: s, failing_before: task::failing(),
--
233: impl Drop for ForbidUnwind {
234: fn drop(&mut self) {
librustuv/lib.rs:391:1-391:1 -fn- definition:
pub fn uv_error_to_io_error(uverr: UvError) -> IoError {
unsafe {
// Importing error constants
references:- 54librustuv/timeout.rs:
librustuv/uvio.rs:
librustuv/file.rs:
librustuv/net.rs:
librustuv/process.rs:
librustuv/pipe.rs:
librustuv/tty.rs:
librustuv/file.rs:
librustuv/lib.rs:442:23-442:23 -NK_AS_STR_TODO- definition:
/// The uv buffer type
pub type Buf = uvll::uv_buf_t;
pub fn empty_buf() -> Buf {
references:- 8445: pub fn empty_buf() -> Buf {
446: uvll::uv_buf_t {
--
452: /// Borrow a slice to a Buf
453: pub fn slice_to_uv_buf(v: &[u8]) -> Buf {
454: let data = v.as_ptr();
librustuv/net.rs:
585: extern fn recv_cb(handle: *uvll::uv_udp_t, nread: ssize_t, buf: *Buf,
586: addr: *libc::sockaddr, _flags: c_uint) {
librustuv/stream.rs:
37: struct ReadContext {
38: buf: Option<Buf>,
39: result: ssize_t,
--
241: // return all the data read (even if it didn't fill the whole buffer).
242: extern fn read_cb(handle: *uvll::uv_stream_t, nread: ssize_t, _buf: *Buf) {
243: uvdebug!("read_cb {}", nread);
librustuv/net.rs:
576: _suggested_size: size_t,
577: buf: *mut Buf) {
578: unsafe {