コード例 #1
0
  public void bsync(NativeObject jsRWB) {
    Map<String, Object> jRWB = (Map) Context.jsToJava(jsRWB, Map.class);

    RWBStatement stmt = RWBStatement.make();
    Object req = jRWB.get("request");
    if (req != null) {
      if (req instanceof BEvent) {
        stmt = stmt.request((BEvent) req);
      } else if (req instanceof NativeArray) {
        NativeArray arr = (NativeArray) req;
        stmt =
            stmt.request(
                Arrays.asList(arr.getIndexIds())
                    .stream()
                    .map(i -> (BEvent) arr.get(i))
                    .collect(toSet()));
      }
    }

    stmt =
        stmt.waitFor(convertToEventSet(jRWB.get("waitFor")))
            .block(convertToEventSet(jRWB.get("block")))
            .breakUpon(convertToEventSet(jRWB.get("breakUpon")));

    bthread.bsync(stmt);
  }
コード例 #2
0
 /**
  * BSync call, used by the JS programs. Works as follows:
  *
  * <ol>
  *   <li>Creates an {@link RWBStatement} using the parameters
  *   <li>Captures a continuation
  *   <li>Cleans up current Javascript context
  *   <li>Throws the continuation
  * </ol>
  *
  * @param requestedEvents
  * @param waitedEvents
  * @param blockedEvents
  * @deprecated use the named arguments version
  */
 public void bsync(
     Set<? extends BEvent> requestedEvents, EventSet waitedEvents, EventSet blockedEvents) {
   System.err.println(
       "warning: positional bsync (bsync(r,w,b)) is deprecated. Use named arguemnt bsync (bsync({requested:...})) instead.");
   bthread.bsync(
       RWBStatement.make().request(requestedEvents).waitFor(waitedEvents).block(blockedEvents));
 }
コード例 #3
0
 public void setBreakUponHandler(Object aPossibleHandler) {
   bthread.setBreakUponHandler(
       (aPossibleHandler instanceof Function)
           ? Optional.of((Function) aPossibleHandler)
           : Optional.empty());
 }