Examples of EInternalPort


Examples of erjang.EInternalPort

      throw ERT.badarg(node_arg, cid_arg, type_arg);
    }
   
    /** first arg is ok */
   
    EInternalPort port = cid_arg.testInternalPort();
    if (port == null) {
      throw ERT.badarg(node_arg, cid_arg, type_arg);
    }

    ETuple t = type_arg.testTuple();
    if (t.arity() != 4) {
      throw ERT.badarg(node_arg, cid_arg, type_arg);
    }
   
    ESmall flags = t.elm(1).testSmall();
    ESmall version = t.elm(2).testSmall();
    if (flags == null || version == null) {
      throw ERT.badarg(node_arg, cid_arg, type_arg);
    }

    EPeer n = EPeer.get_or_create(node, creation, port, flags.value, version.value);
   
    EDriverTask task = port.task();
    if (task != null) {
      task.node(n);

      /*TODO:
    send_nodes_mon_msgs(BIF_P,
View Full Code Here

Examples of erjang.EInternalPort

      driver = new LockingDriverInstance(driver, new kilim.ReentrantLock());
    }
   
    this.owner = owner;
    this.instance = driver;
    this.port = new EInternalPort(this);
    driver.setTask(this);
   

    all_ports.put(id, this);
  }
View Full Code Here

Examples of erjang.EInternalPort

  @Override
  protected void readyOutput(SelectableChannel evtthrows Pausable {


    EInternalPort ix = port();

    if (is_connected()) {
      ByteBuffer[] iov;
      if ((iov = driver_peekq()) == null) {
        select(evt, ERL_DRV_WRITE, SelectMode.CLEAR);
View Full Code Here

Examples of erjang.EInternalPort

  static EAtom am_spawn_executable = EAtom.intern("spawn_executable");

  @BIF
  static EObject port_connect(EProc proc, EObject arg_port, EObject arg_pid) throws Pausable
  {
    EInternalPort iport;
    EInternalPID ipid;
   
    if ((iport=arg_port.testInternalPort()) == null) {
      EAtom port_name = arg_port.testAtom();
      EObject resolved;
      if (port_name != null
        && (resolved=ERT.whereis(port_name)) != ERT.am_undefined
        && (iport=resolved.testInternalPort()) != null) {
        // ok //
      } else {
        throw ERT.badarg(arg_port, arg_pid);
      }
    }

    if ((ipid=arg_pid.testInternalPID()) == null) {
      EAtom pid_name = arg_pid.testAtom();
      EObject resolved;
      if (pid_name != null
        && (resolved=ERT.whereis(pid_name)) != ERT.am_undefined
        && (ipid=resolved.testInternalPID()) != null) {
        // ok //
      } else {
        throw ERT.badarg(arg_port, arg_pid);
      }
    }

    // TODO: what if port or pid args are already dead?
   
    iport.set_owner(ipid);
    ipid.task().link_to(iport);
   
    return ERT.TRUE;
   
  }
View Full Code Here

Examples of erjang.EInternalPort

  }
 
  @BIF
  static EObject port_command(EProc proc, EObject port, EObject data)
      throws Pausable {
    EInternalPort p = port.testInternalPort();

    if (log.isLoggable(Level.FINER))
    log.finer("port_command "+port+", "+data);
   

   
    if (p == null) {
      port = ERT.whereis(port);
      if (port == ERT.am_undefined)
        port = null;
      else
        p = port.testInternalPort();
    }

    List<ByteBuffer> ovec = new ArrayList<ByteBuffer>();
    if (p == null || !data.collectIOList(ovec)) {
      if (log.isLoggable(Level.WARNING)) {
        log.warning("collect failed! or p==null: "+p);
      }
      throw ERT.badarg(port, data);
    }

    ByteBuffer[] out = new ByteBuffer[ovec.size()];
    ovec.toArray(out);

    if (log.isLoggable(Level.FINE)) {
      log.fine("EVEC: ");
      TCPINet.dump_buffer(out);
    }
   
    // log.finer("packing "+data+"::"+data.getClass().getName()+" -> "+ovec);

    p.command(proc.self_handle(), out);

    return ERT.TRUE;
  }
View Full Code Here

Examples of erjang.EInternalPort

  /* TODO: worry about the options argument */
  @BIF
  static EObject port_command(EProc proc, EObject port, EObject data, EObject options)
      throws Pausable {
    EInternalPort p = port.testInternalPort();

    if (log.isLoggable(Level.FINE))
      log.fine("port_command "+port+", "+data);
   

   
    if (p == null) {
      port = ERT.whereis(port);
      if (port == ERT.am_undefined)
        port = null;
      else
        p = port.testInternalPort();
    }

    List<ByteBuffer> ovec = new ArrayList<ByteBuffer>();
    if (p == null || !data.collectIOList(ovec)) {
      if (log.isLoggable(Level.FINE)) {
        log.fine("collect failed! or p==null: "+p);
      }
      throw ERT.badarg(port, data);
    }

    ByteBuffer[] out = new ByteBuffer[ovec.size()];
    ovec.toArray(out);

    EDriverInstance.dump_buffer(log, "EVEC: ", out);
   
    // log.fine("packing "+data+"::"+data.getClass().getName()+" -> "+ovec);

    p.command(proc.self_handle(), out);

    return ERT.TRUE;
  }
View Full Code Here

Examples of erjang.EInternalPort

      }
    }

  static EObject port_control0(EProc proc, EObject port, EObject operation,
      EObject data) throws Pausable {
    EInternalPort p = port.testInternalPort();

    if (p == null) {
      port = ERT.whereis(port);
      if (port == ERT.am_undefined)
        port = null;

      p = port.testInternalPort();
    }

    ESmall op = operation.testSmall();

    List<ByteBuffer> ovec = new ArrayList<ByteBuffer>();
    if (p == null || op == null || !data.collectIOList(ovec)) {
      throw ERT.badarg(port, operation, data);
    }

    ByteBuffer cmd = flatten(ovec);
   
    // TODO: improve exception handling/wrapping here so we get
    // ErlangException types only!
    return p.control(proc, op.value, cmd);
  }
View Full Code Here

Examples of erjang.EInternalPort

  }

  @BIF
  static EObject port_call(EProc proc, EObject port, EObject operation,
      EObject data) throws Pausable {
    EInternalPort p = port.testInternalPort();

    if (p == null) {
      port = ERT.whereis(port);
      if (port == ERT.am_undefined)
        port = null;

      p = port.testInternalPort();
    }

    ESmall op = operation.testSmall();

    if (p == null || op == null) {
      throw ERT.badarg(port, operation, data);
    }

    // TODO: improve exception handling/wrapping here so we get
    // ErlangException types only!
    return p.call(proc, op.value, data);
  }
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.