Examples of ERef


Examples of erjang.ERef

    if (priority != null) {
      // may throw badarg!
      p2.process_flag(am_priority, priority);
    }
   
    ERef ref = null;
    if (monitor) {
      ref = ERT.getLocalNode().createRef();
     
      if (!self.monitor(p2.self_handle(), p2.self_handle(), ref)) {
        throw new InternalError("cannot monitor new process?");
View Full Code Here

Examples of erjang.ERef

    // case 1: object is a PID
    EHandle h = EHandle.cast(object);
    if (h != null)
    {  
      ERef ref = ERT.getLocalNode().createRef();
      if (!self.monitor(h, h, ref)) {
        self.mbox_send(ETuple.make(ERT.am_DOWN, ref, am_process, object, ERT.am_noproc));
      }
      return ref;
    }

    // case 2: object is a name
    EAtom name;
    if (h == null && (name=object.testAtom()) != null) {
      ERef ref = ERT.getLocalNode().createRef();
      boolean success = false;
     
      object = new ETuple2(name, ErlDist.node());
     
      if ((h = ERT.whereis(name).testHandle()) != null)
      {  
        success = self.monitor(h, object, ref);
     
     
      if (!success) {
        self.mbox_send(ETuple.make(ERT.am_DOWN, ref, am_process, object, ERT.am_noproc));
      }

      return ref;
    }

    // case 3: object is {name, node}
    ETuple tup;
    EAtom node;
    if ((tup=object.testTuple()) != null
      && tup.arity()==2
      && (name=tup.elm(1).testAtom()) != null
      && (node=tup.elm(2).testAtom()) != null)
    {
      if (node == ErlDist.node()) {

        ERef ref = ERT.getLocalNode().createRef();
        boolean success = false;
       
        if ((h = ERT.whereis(name).testHandle()) != null)
        {  
          success = self.monitor(h, object, ref);
       
       
        if (!success) {
          self.mbox_send(ETuple.make(ERT.am_DOWN, ref, am_process, object, ERT.am_noproc));
        }

        return ref;
       
      } else {
       
        EPeer peer = (EPeer) EPeer.get(node);
        if (peer != null) {
          ERef ref = ERT.getLocalNode().createRef();
          self.monitor(tup, ref);
          peer.dsig_monitor(self.self_handle(), name, ref);
          return ref;
        }
View Full Code Here

Examples of erjang.ERef

  static public EObject demonitor(EProc self, EObject ref, EObject options) throws Pausable {
    return demonitor((ETask<?>)self, ref, options);
  }

  static public 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);
View Full Code Here

Examples of erjang.ERef

   
    if (!ERT.getLocalNode().isALive()) {
      return ENode.am_nonode_at_nohost;
    }
   
    ERef ref;
    if ((ref=name.testReference()) != null)
      return ref.node();
   
    EHandle handle;
    if ((handle=name.testHandle()) != null)
      return handle.node();
   
View Full Code Here

Examples of erjang.ERef

    EHandle handle;
    if ((handle=name.testHandle()) != null) {
      return handle.node();
    }
   
    ERef ref;
    if ((ref=name.testReference()) != null) {
      return ref.node();
    }
   
    return null;
  }
View Full Code Here

Examples of erjang.ERef

    return res;
  }

  @BIF
  public static EString ref_to_list(EObject obj) {
    ERef ref = obj.testReference();
    if (ref == null)
      throw ERT.badarg(obj);
    return new EString(ref.toString());
  }
View Full Code Here

Examples of erjang.ERef

    return task.get_monitored_process(monitor);
  }

 
  protected ERef driver_monitor_process(EPID pid) throws Pausable {
    ERef ref = ERT.getLocalNode().createRef();
   
    if (!task.monitor(pid, pid, ref)) {
      port().send(port(), ETuple.make(ERT.am_DOWN, ref, ErlProc.am_process, pid, ERT.am_noproc));
    }
   
View Full Code Here

Examples of erjang.ERef

          return;
        }
      } else if ((tup = msg.testTuple()) != null && tup.arity() == 5) {
        // {'DOWN', ref, process, pid, reason}
        if (tup.elm(1) == ERT.am_DOWN) {
          ERef ref = tup.elm(2).testReference();
          instance.processExit(ref);
        }

      }
View Full Code Here

Examples of erjang.ERef

    switch (state) {
    case TCP_STATE_ACCEPTING: {
      long time_left;
        MultiTimerData mtd = null, omtd = null;
        ERef monitor;

        if ((monitor = driver_monitor_process(caller)) == null) {
          return ctl_xerror(NOPROC);
        }
       
        AsyncOp op = deq_async_w_tmo();
        if (op.timeout != INET_INFINITY) {
          time_left = driver_read_timer();
          driver_cancel_timer();
         
          if (time_left <= 0) {
            time_left = 1;
          }
          omtd = add_multi_timer(op.caller, time_left);
        }
        enq_old_multi_op(op, omtd);
        if (timeout != INET_INFINITY) {
          mtd = add_multi_timer(caller, timeout);
        }
        short id = enq_multi_op(TCP_REQ_ACCEPT, caller, mtd, monitor);
        byte[] data = new byte[2];
        data[0] = (byte) (id >>> 8);
        data[1] = (byte) (id & 0xff);
        state = TCP_STATE_MULTI_ACCEPTING;
        return ctl_reply(INET_REP_OK, data);
    }
      // break;

    case TCP_STATE_MULTI_ACCEPTING:
    {
        MultiTimerData mtd = null, omtd = null;
        ERef monitor;

        if ((monitor = driver_monitor_process(caller)) == null) {
          return ctl_xerror(NOPROC);
        }
       
        if (timeout != INET_INFINITY) {
          mtd = add_multi_timer(caller, timeout);
        }
       
        short id = enq_multi_op(TCP_REQ_ACCEPT, caller, mtd, monitor);
        byte[] data = new byte[2];
        data[0] = (byte) (id >>> 8);
        data[1] = (byte) (id & 0xff);
        return ctl_reply(INET_REP_OK, data);

    }
      // break;

    case TCP_STATE_LISTEN:
      ByteBuffer reply = ByteBuffer.allocate(2);
      InetSocket sock;
      try {
        sock = fd.accept();
      } catch (IOException e) {
        return ctl_error(IO.exception_to_posix_code(e));
      }
      if (sock == null) {
        // async ...
        ERef monitor = driver_monitor_process(caller);
        if (monitor == null) {
          return ctl_xerror(NOPROC);
        }
        enq_async_w_tmo(caller, reply, TCP_REQ_ACCEPT, timeout, monitor);
        state = TCP_STATE_ACCEPTING;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.