Exemplo n.º 1
0
  public static EObject demonitor(ETask<?> self, EObject ref, EObject options) throws Pausable {
    ERef r = ref.testReference();

    ESeq o = options.testSeq();

    if (r == null || o == null) throw ERT.badarg(ref, options);

    boolean flush = (!o.isNil() && o.head() == am_flush);

    EObject found = self.demonitor(r);

    if (found == null) {
      return ERT.FALSE;
    }

    EHandle h;
    ETuple tup;
    EAtom name;
    EAtom node;
    if ((h = found.testHandle()) != null) {
      h.remove_monitor(self.self_handle(), r, flush);
    } else if ((tup = found.testTuple()) != null
        && tup.arity() == 2
        && (name = tup.elm(1).testAtom()) != null
        && (node = tup.elm(2).testAtom()) != null) {

      EAbstractNode n = EAbstractNode.get_or_connect(self, node);
      if (n != null) {
        n.dsig_demonitor(self.self_handle(), r, name);
      }
    }

    if (flush && (self instanceof EProc)) {
      flush_monitor_message.invoke((EProc) self, new EObject[] {ref, ERT.am_ok});
    }

    return ERT.TRUE;
  }