Sha256: da8e2fd51cc3dd51eb8abdbf57b4a6c531e5d0a676d29e6bc9b6162686b6f0e2

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

<?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>attach (Rev::Watcher)</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>/**
 *  call-seq:
 *    Rev::Watcher.attach(loop) -&gt; Rev::Watcher
 * 
 * Attach the watcher to the given Rev::Loop.  If the watcher is already attached
 * to a loop, detach it from the old one and attach it to the new one.
 */
static VALUE Rev_Watcher_attach(VALUE self, VALUE loop)
{
  VALUE loop_watchers, active_watchers;
    
  loop_watchers = rb_iv_get(loop, &quot;@watchers&quot;);

  if(loop_watchers == Qnil) {
    loop_watchers = rb_ary_new();
    rb_iv_set(loop, &quot;@watchers&quot;, loop_watchers);
  }

  /* Add us to the loop's array of active watchers.  This is mainly done
   * to keep the VM from garbage collecting watchers that are associated
   * with a loop (and also lets you see within Ruby which watchers are
   * associated with a given loop), but isn't really necessary for any 
   * other reason */
  rb_ary_push(loop_watchers, self);

  active_watchers = rb_iv_get(loop, &quot;@active_watchers&quot;);
  if(active_watchers == Qnil)
    active_watchers = INT2NUM(1);
  else
    active_watchers = INT2NUM(NUM2INT(active_watchers) + 1);
  rb_iv_set(loop, &quot;@active_watchers&quot;, active_watchers);

  return self;
}</pre>
</body>
</html>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rev-0.1.2 doc/rdoc/classes/Rev/Watcher.src/M000113.html