Пример #1
0
  @BIF
  public static ESeq map(EProc proc, EObject f, EObject s) throws Pausable {
    EFun fun = f.testFunction2(1);
    ESeq seq = s.testSeq();
    if (fun == null || seq == null) throw ERT.badarg(f, s);

    EObject[] arg = new EObject[1];

    ESeq rev = ERT.NIL;
    for (; !seq.isNil(); seq = seq.tail()) {
      arg[0] = seq.head();
      rev = rev.cons(fun.invoke(proc, arg));
    }

    return reverse(rev, ERT.NIL);
  }
Пример #2
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;
  }