@@ -289,62 +289,6 @@ impl<'conn> Notifications<'conn> {
289289 _ => unreachable ! ( )
290290 }
291291 }
292-
293- /*
294- /// Returns the oldest pending notification
295- ///
296- /// If no notifications are pending, blocks for up to `timeout` time, after
297- /// which `None` is returned.
298- ///
299- /// ## Example
300- ///
301- /// ```rust,no_run
302- /// # #![allow(unstable)]
303- /// use std::old_io::{IoError, IoErrorKind};
304- /// use std::time::Duration;
305- ///
306- /// use postgres::Error;
307- ///
308- /// # let conn = postgres::Connection::connect("", &postgres::SslMode::None).unwrap();
309- /// match conn.notifications().next_block_for(Duration::seconds(2)) {
310- /// Some(Ok(notification)) => println!("notification: {}", notification.payload),
311- /// Some(Err(e)) => println!("Error: {:?}", e),
312- /// None => println!("Wait for notification timed out"),
313- /// }
314- /// ```
315- pub fn next_block_for(&mut self, timeout: Duration) -> Option<Result<Notification>> {
316- if let Some(notification) = self.next() {
317- return Some(Ok(notification));
318- }
319-
320- let mut conn = self.conn.conn.borrow_mut();
321- if conn.desynchronized {
322- return Some(Err(Error::StreamDesynchronized));
323- }
324-
325- let end = SteadyTime::now() + timeout;
326- loop {
327- let timeout = max(Duration::zero(), end - SteadyTime::now()).num_milliseconds() as u64;
328- conn.stream.set_read_timeout(Some(timeout));
329- match conn.read_one_message() {
330- Ok(Some(NotificationResponse { pid, channel, payload })) => {
331- return Some(Ok(Notification {
332- pid: pid,
333- channel: channel,
334- payload: payload
335- }))
336- }
337- Ok(Some(_)) => unreachable!(),
338- Ok(None) => {}
339- Err(IoError { kind: IoErrorKind::TimedOut, .. }) => {
340- conn.desynchronized = false;
341- return None;
342- }
343- Err(e) => return Some(Err(Error::IoError(e))),
344- }
345- }
346- }
347- */
348292}
349293
350294/// Contains information necessary to cancel queries for a session.
0 commit comments