Package erjang

Examples of erjang.EObject


  @Override
  public EObject select(final EMatchSpec matcher, int limit) {
   
    IPersistentMap map = deref();
   
    EObject key = matcher.getTupleKey(keypos1);
   
    if (key == null) {
      ESetCont cont0 = new ESetCont(matcher, map.seq(), ordered, limit);
      return cont0.select();
     
    } else {
      ETuple candidate = (ETuple) map.valAt(key);
      if (candidate == null) return Native.am_$end_of_table;
      EObject res;
      if ((res = matcher.match(candidate)) != null) {
        return new ETuple2(ERT.NIL.cons(res), Native.am_$end_of_table);
      }
    }
   
View Full Code Here


  public EInteger select_delete(final EMatchSpec matcher) {   
    int delete_count = in_tx(new WithMap<Integer>() {

      @Override
      protected Integer run(IPersistentMap map) {
        EObject key = matcher.getTupleKey(keypos1);
        int count = 0;
       
        if (key == null) {
          for (Map.Entry<EObject, ETuple> ent : ((Map<EObject, ETuple>) map).entrySet()) {   
            ETuple val = ent.getValue();
View Full Code Here

      private ETuple update(ETuple rec, int idx, EInteger incr) {

        EInteger old = rec.elm(idx).testInteger();
        if (old == null) return null;
        EObject val = old.add(incr);
        rec = ErlBif.setelement(idx, rec, val);

        return rec;
      }
     
      private ETuple update(ETuple rec, int idx, EInteger incr, EInteger threshold, EInteger setvalue) {

        EInteger old = rec.elm(idx).testInteger();
        if (old == null) return null;
        ENumber val = old.add(incr);
       
        if (incr.is_ge(ESmall.ZERO)) {

          if (threshold.is_lt(val)) {
            val = setvalue;
          }
         
        } else {
         
          if (val.is_lt(threshold)) {
            val = setvalue;
          }
        }

       
View Full Code Here

      throw ERT.badarg();

    for (; settings != null && !settings.isNil(); settings = settings
        .tail().testCons()) {

      EObject val = settings.head();
      ETuple tup;
      if ((tup = val.testTuple()) != null) {
        ETuple2 tup2;
        if ((tup2 = ETuple2.cast(tup)) != null) {

          if (tup2.elem1 == am_args) {
            ESeq list = tup2.elem2.testSeq();
View Full Code Here

 
  @Override
  public void execute() throws Pausable {
    try {

      EObject result = null;
      try {

        // driver main loop
        main_loop();
View Full Code Here

   */
  protected void main_loop() throws Exception, Pausable {

    /** out is used locally later, but we allocate it once and for all. */
    List<ByteBuffer> out = new ArrayList<ByteBuffer>();
    EObject msg;

    next_message: while (true) {

      /** if the driver has a registered timeout ... handle that */
      if (abs_timeout == 0) {
        msg = mbox.get();
      } else {
        msg = null;
        long timeout = abs_timeout - System.currentTimeMillis();
        if (timeout > 0) {
          msg = mbox.get(timeout);
        }
        if (msg == null) {
          abs_timeout = 0;
          this.instance.timeout();
          continue next_message;
        }
      }

      ETuple2 t2;
      EPortControl ctrl;
      ETuple3 t3;
      ETuple4 t4;
      ETuple tup;
      if ((t2 = ETuple2.cast(msg)) != null) {

        EObject sender = t2.elem1;

        ETuple2 cmd;
        if ((cmd = ETuple2.cast(t2.elem2)) != null) {
          // cmd must be one of
          // {command, iodata()}
          // {connect, PID}

          if (cmd.elem1 == EPort.am_command) {
            if (cmd.elem2.collectIOList(out)) {
              EHandle caller = sender.testHandle();
             
              if (caller == null) {
                log.warning("*** sender is null? "+sender);
              }
             
View Full Code Here

  public EObject call(EProc caller, int op, EObject data) throws Pausable {
    if (pstate != STATE.RUNNING) {
      throw ERT.badarg();
    }

    EObject result = instance.call(caller.self_handle(), op, data);

    if (result == null) {
      return ERT.NIL;
    } else {
      return result;
View Full Code Here

  /** data is at 0 .. out.position()
   * @throws Pausable */
  private int tcp_message(ByteBuffer out) throws Pausable {
    int hsz = this.hsz;

    EObject msg;
    EObject data;

    if (mode == INET_MODE_LIST) {
      out.flip();
      data = EString.make(out);
    } else {
View Full Code Here

      return -1;

    if (log.isLoggable(Level.FINER))
      log.finer("deq " + op.caller + "::" + op.id);

    EObject data;
    if (mode == INET_MODE_LIST) {
      out.flip();
      data = EString.make(out);
    } else {
      // TODO: FIGURE OUT IF THIS IS RIGHT
View Full Code Here

    }
  }

  private void out_byte(int b) {
    ByteBuffer buf = ByteBuffer.wrap(new byte[] { (byte) b });
    EObject out;

    if (task.send_binary_data()) {
      out = EBinary.make(buf);
    } else {
      out = EString.make(buf);
View Full Code Here

TOP

Related Classes of erjang.EObject

Copyright © 2018 www.massapicom. 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.