File: M000033.html

package info (click to toggle)
libfam-ruby 0.2.0-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 356 kB
  • ctags: 123
  • sloc: ansic: 412; ruby: 119; makefile: 44
file content (60 lines) | stat: -rw-r--r-- 1,562 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
  <title>next_event (Fam::Connection)</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
</head>
<body class="standalone-code">
  <pre>/*
 * Get the next event from the event queue, or block until an event is
 * available.
 *
 * Raises a Fam::Error exception if FAM couldn't check for pending
 * events, or if FAM-Ruby couldn't get the next FAM event.
 * 
 * Aliases:
 *   Fam::Connection#next_ev
 *   Fam::Connection#ev
 *
 * Examples:
 *   ev = fam.next_event
 *
 */
static VALUE fam_conn_next_ev(VALUE self)
{
  FAMConnection *conn;
  FAMEvent *ev = NULL;
  int err;

  Data_Get_Struct(self, FAMConnection, conn);

  if (!(err = FAMPending(conn))) {
    int fd = FAMCONNECTION_GETFD(conn);
    fd_set rfds;

    FD_ZERO(&amp;rfds);
    do {
      if (err == -1)
        rb_raise(eError, &quot;Couldn't check for pending FAM events: %s&quot;, fam_error());
      FD_SET(fd, &amp;rfds);
      rb_thread_select(fd + 1, &amp;rfds, NULL, NULL, NULL);
    } while (!FD_ISSET(fd, &amp;rfds) || !(err = FAMPending(conn)));
  }

  ev = ALLOC(FAMEvent);
  err = FAMNextEvent(conn, ev);

  if (err == -1) {
    xfree(ev);
    rb_raise(eError, &quot;Couldn't get next FAM event: %s&quot;, fam_error());
  }

  return wrap_ev(ev);
}</pre>
</body>
</html>