Generate a in-stream DR event which pushes an event buffer to topend
171017
public void generateDREvent(EventType type, long txnId, long uniqueId, long lastCommittedSpHandle,
            long spHandle, byte[] payloads) {
        m_ee.quiesce(lastCommittedSpHandle);
        ByteBuffer paramBuffer = m_ee.getParamBufferForExecuteTask(32 + 16 + payloads.length);
        paramBuffer.putInt(type.ordinal());
        paramBuffer.putLong(uniqueId);
        paramBuffer.putLong(lastCommittedSpHandle);
        paramBuffer.putLong(spHandle);
        // adding txnId and undoToken to make generateDREvent undoable
        paramBuffer.putLong(txnId);
        paramBuffer.putLong(getNextUndoToken(m_currentTxnId));
        paramBuffer.putInt(payloads.length);
        paramBuffer.put(payloads);
        m_ee.executeTask(TaskType.GENERATE_DR_EVENT, paramBuffer);
    }
1220996
private void startDTD()
        throws XMLStreamException
    {
        /* 21-Nov-2004, TSa: Let's make sure that the buffer gets cleared
         *   at this point. Need not start branching yet, however, since
         *   DTD event is often skipped.
         */
        mTextBuffer.resetInitialized();

        /* So, what we need is:<code>
         *  <!DOCTYPE' S Name (S ExternalID)? S? ('[' intSubset ']' S?)? '>
         *</code>. And we have already read the DOCTYPE token.
         */

        char c = getNextInCurrAfterWS(SUFFIX_IN_DTD);
        if (mCfgNsEnabled) {
            String str = parseLocalName(c);
            c = getNextChar(SUFFIX_IN_DTD);
            if (c == ':') { // Ok, got namespace and local name
                mRootPrefix = str;
                mRootLName = parseLocalName(getNextChar(SUFFIX_EOF_EXP_NAME));
            } else if (c <= CHAR_SPACE || c == '[' || c == '>') {
                // ok to get white space or '[', or closing '>'
                --mInputPtr; // pushback
                mRootPrefix = null;
                mRootLName = str;
            } else {
                throwUnexpectedChar(c, " in DOCTYPE declaration; expected '[' or white space.");
            }
        } else {
            mRootLName = parseFullName(c);
            mRootPrefix = null;
        }

        // Ok, fine, what next?
        c = getNextInCurrAfterWS(SUFFIX_IN_DTD);
        if (c != '[' && c != '>') {
            String keyw = null;
            
            if (c == 'P') {
                keyw = checkKeyword(getNextChar(SUFFIX_IN_DTD), "UBLIC");
                if (keyw != null) {
                    keyw = "P" + keyw;
                } else {
                    if (!skipWS(getNextChar(SUFFIX_IN_DTD))) {
                        throwUnexpectedChar(c, SUFFIX_IN_DTD+"; expected a space between PUBLIC keyword and public id");
                    }
                    c = getNextCharFromCurrent(SUFFIX_IN_DTD);
                    if (c != '"' && c != '\'') {
                        throwUnexpectedChar(c, SUFFIX_IN_DTD+"; expected a public identifier.");
                    }
                    mDtdPublicId = parsePublicId(c, SUFFIX_IN_DTD);
                    if (mDtdPublicId.length() == 0) {
                        // According to XML specs, this isn't illegal?
                        // however, better report it as empty, not null.
                        //mDtdPublicId = null;
                    }
                    if (!skipWS(getNextChar(SUFFIX_IN_DTD))) {
                        throwUnexpectedChar(c, SUFFIX_IN_DTD+"; expected a space between public and system identifiers");
                    }
                    c = getNextCharFromCurrent(SUFFIX_IN_DTD);
                    if (c != '"' && c != '\'') {
                        throwParseError(SUFFIX_IN_DTD+"; expected a system identifier.");
                    }
                    mDtdSystemId = parseSystemId(c, mNormalizeLFs, SUFFIX_IN_DTD);
                    if (mDtdSystemId.length() == 0) {
                        // According to XML specs, this isn't illegal?
                        // however, better report it as empty, not null.
                        //mDtdSystemId = null;
                    }
                }
            } else if (c == 'S') {
                mDtdPublicId = null;
                keyw = checkKeyword(getNextChar(SUFFIX_IN_DTD), "YSTEM");
                if (keyw != null) {
                    keyw = "S" + keyw;
                } else {
                    c = getNextInCurrAfterWS(SUFFIX_IN_DTD);
                    if (c != '"' && c != '\'') {
                        throwUnexpectedChar(c, SUFFIX_IN_DTD+"; expected a system identifier.");
                    }
                    mDtdSystemId = parseSystemId(c, mNormalizeLFs, SUFFIX_IN_DTD);
                    if (mDtdSystemId.length() == 0) {
                        // According to XML specs, this isn't illegal?
                        mDtdSystemId = null;
                    }
                }
            } else {
                if (!isNameStartChar(c)) {
                    throwUnexpectedChar(c, SUFFIX_IN_DTD+"; expected keywords 'PUBLIC' or 'SYSTEM'.");
                } else {
                    --mInputPtr;
                    keyw = checkKeyword(c, "SYSTEM"); // keyword passed in doesn't matter
                }
            }
            
            if (keyw != null) { // error:
                throwParseError("Unexpected keyword '"+keyw+"'; expected 'PUBLIC' or 'SYSTEM'");
            }
            
            // Ok, should be done with external DTD identifier:
            c = getNextInCurrAfterWS(SUFFIX_IN_DTD);
        }
        
        if (c == '[') { // internal subset
            ;
        } else {
            if (c != '>') {
                throwUnexpectedChar(c, SUFFIX_IN_DTD+"; expected closing '>'.");
            }
        }
        
        /* Actually, let's just push whatever char it is, back; this way
         * we can lazily initialize text buffer with DOCTYPE declaration
         * if/as necessary, even if there's no internal subset.
         */
        --mInputPtr; // pushback
        mTokenState = TOKEN_STARTED;
    }
857680
function listen(event, spark) {
    if ('end' === event) return function end() {
      if (!spark.streams) return;

      for (var stream in spark.streams) {
        stream = spark.streams[stream];
        if (stream.end) stream.end();
      }
    };

    if ('readyStateChange' === event) return function change(reason) {
      if (!spark.streams) return;

      for (var stream in spark.streams) {
        stream = spark.streams[stream];
        stream.readyState = spark.readyState;
        if (stream.emit) emit.call(stream, event, reason);
      }
    };

    return function proxy() {
      if (!spark.streams) return;

      var args = Array.prototype.slice.call(arguments, 0);

      for (var stream in spark.streams) {
        if (stream.emit) emit.call(stream, [event].concat(args));
      }
    };
  }
931726
def _ExportEvent(self, output_module, event, deduplicate_events=True):
    
    if event.timestamp != self._export_event_timestamp:
      self._FlushExportBuffer(
          output_module, deduplicate_events=deduplicate_events)
      self._export_event_timestamp = event.timestamp

    self._export_event_heap.PushEvent(event)
1243283
function eventToPromise (emitter, event, opts) {
  var cancel
  var promise = new Promise(function (resolve, reject) {
    var addEvent = makeEventAdder(emitter, opts && opts.array)
    cancel = function () {
      cancel = noop
      addEvent.cleanUp()
    }

    addEvent(event, resolve)

    if (!opts || !opts.ignoreErrors) {
      addEvent((opts && opts.error) || 'error', reject)
    }
  })
  promise.cancel = function () { return cancel() }

  return promise
}
91301
private static void generateToCConnection(Map<String, List<TraceEvent>> events, FileWriter fw)
      throws Exception
   {
      writeString(fw, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"");
      writeEOL(fw);
      writeString(fw, "                      \"http://www.w3.org/TR/html4/loose.dtd\">");
      writeEOL(fw);

      writeString(fw, "<html>");
      writeEOL(fw);

      writeString(fw, "<head>");
      writeEOL(fw);

      writeString(fw, "<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">");
      writeEOL(fw);

      writeString(fw, "<title>Reference: Connection</title>");
      writeEOL(fw);

      writeString(fw, "</head>");
      writeEOL(fw);

      writeString(fw, "<body style=\"background: #D7D7D7;\">");
      writeEOL(fw);

      writeString(fw, "<h1>Reference: Connection</h1>");
      writeEOL(fw);

      writeString(fw, "<ul>");
      writeEOL(fw);

      for (String id : events.keySet())
      {
         writeString(fw, "<li><a href=\"#" + id + "\">" + id + "</a></li>");
         writeEOL(fw);
      }

      writeString(fw, "</ul>");
      writeEOL(fw);

      for (Map.Entry<String, List<TraceEvent>> entry : events.entrySet())
      {
         writeString(fw, "<a name=\"" + entry.getKey() + "\"><h2>" + entry.getKey() + "</h2></a>");
         writeEOL(fw);

         writeString(fw, "<table>");
         writeEOL(fw);
      
         writeString(fw, "<tr>");
         writeEOL(fw);

         writeString(fw, "<td><b>Timestamp</b></td>");
         writeEOL(fw);

         writeString(fw, "<td><b>ConnectionListener</b></td>");
         writeEOL(fw);

         writeString(fw, "<td><b>ManagedConnectionPool</b></td>");
         writeEOL(fw);

         writeString(fw, "<td><b>Pool</b></td>");
         writeEOL(fw);

         writeString(fw, "</tr>");
         writeEOL(fw);

         for (TraceEvent te : entry.getValue())
         {
            writeString(fw, "<tr>");
            writeEOL(fw);

            writeString(fw, "<td>" + te.getTimestamp() + "</td>");
            writeEOL(fw);
      
            writeString(fw, "<td><a href=\"" + te.getPool() + "/" + te.getConnectionListener() + "/index.html\">" +
                        te.getConnectionListener() + "</a></td>");
            writeEOL(fw);
         
            writeString(fw, "<td>" + te.getManagedConnectionPool() + "</td>");
            writeEOL(fw);
      
            writeString(fw, "<td><a href=\"" + te.getPool() + "/index.html\">" + te.getPool() + "</a></td>");
            writeEOL(fw);
      
            writeString(fw, "</tr>");
            writeEOL(fw);
         }
         
         writeString(fw, "</table>");
         writeEOL(fw);

         writeString(fw, "<p>");
         writeEOL(fw);
      }

      writeString(fw, "<p>");
      writeEOL(fw);

      writeString(fw, "<a href=\"index.html\">Back</a>");
      writeEOL(fw);

      writeString(fw, "</body>");
      writeEOL(fw);

      writeString(fw, "</html>");
      writeEOL(fw);
   }
312880
def stream_tfevents(path, file_api, step=0):
    """"""
    last_step = 0
    row = {}
    buffer = []
    last_row = {}
    for summary in tf.train.summary_iterator(path):
        parsed = tf_summary_to_dict(summary)
        if last_step != parsed["tensorflow_step"]:
            step += 1
            last_step = parsed["tensorflow_step"]
            # TODO: handle time
            if len(row) > 0:
                last_row = to_json(row)
                buffer.append(Chunk("wandb-history.jsonl",
                                    util.json_dumps_safer_history(to_json(row))))
        row.update(parsed)
    file_api._send(buffer)
    return last_row
727640
function realtimeSimulationPipe(stream) {
  const parser = csv.parse({delimeter: ",", columns: true});
  return Bacon
  .fromEvent(stream.pipe(parser), 'data')
  .bufferingThrottle(1000 / 50)
  .map(v => Object.assign({}, v, { time: new Date().getTime() }))
}
260612
function toNodeStream (renderer) {
  let sourceIsReady = true;

  const read = () => {
    // If source is not ready, defer any reads until the promise resolves.
    if (!sourceIsReady) { return false; }

    sourceIsReady = false;
    const pull = pullBatch(renderer, stream);

    return pull.then(result => {
      sourceIsReady = true;
      if (result === EXHAUSTED) {
        return stream.push(null);
      } else {
        if (result !== INCOMPLETE) {
          stream.push(result);
        }
        return read();
      }
    }).catch(err => {
      return stream.emit("error", err);
    });
  };

  const stream = new Readable({ read });

  return stream;
}
1268855
def write_event(self, event):
        """"""
        # Check if event is of type event_pb2.Event proto.
        if not isinstance(event, event_pb2.Event):
            raise TypeError("expected an event_pb2.Event proto, "
                            " but got %s" % type(event))
        return self._write_serialized_event(event.SerializeToString())
718692
function eventMessageChunker(buffer) {
    /** @type Buffer[] */
    var messages = [];
    var offset = 0;

    while (offset < buffer.length) {
        var totalLength = buffer.readInt32BE(offset);

        // create new buffer for individual message (shares memory with original)
        var message = buffer.slice(offset, totalLength + offset);
        // increment offset to it starts at the next message
        offset += totalLength;

        messages.push(message);
    }

    return messages;
}
802163
function EventDevPing (device){
        adapter.Debug (7, "EventDevPing devid=%s name=%s", device.devid, device.name);
         
        var msg = 
            {type : 3
            ,devid: device.devid
        };
        adapter.BroadcastJson (msg);
    }
880023
public void sendEvent(EventBuilder eventBuilder) {
        if (!Util.isNullOrEmpty(release)) {
            eventBuilder.withRelease(release.trim());
            if (!Util.isNullOrEmpty(dist)) {
                eventBuilder.withDist(dist.trim());
            }
        }

        if (!Util.isNullOrEmpty(environment)) {
            eventBuilder.withEnvironment(environment.trim());
        }

        if (!Util.isNullOrEmpty(serverName)) {
            eventBuilder.withServerName(serverName.trim());
        }

        for (Map.Entry<String, String> tagEntry : tags.entrySet()) {
            eventBuilder.withTag(tagEntry.getKey(), tagEntry.getValue());
        }

        for (Map.Entry<String, Object> extraEntry : extra.entrySet()) {
            eventBuilder.withExtra(extraEntry.getKey(), extraEntry.getValue());
        }

        runBuilderHelpers(eventBuilder);
        Event event = eventBuilder.build();
        sendEvent(event);
    }
526440
function _onLoadEventFired(event, res) {
        // res = {timestamp}
        Inspector.DOM.getDocument(function onGetDocument(res) {
            exports.trigger("getDocument", res);
            // res = {root}
            _idToNode = {};
            _pendingRequests = 0;
            exports.root = new DOMNode(exports, res.root);
        });
    }
1321369
function EventDispatcher (tree, definition) {
  if (!tree || !_.isObject(tree) || !_.isFunction(tree.getViewBuilders)) {
    var err = new Error('Please pass a valid tree!');
    debug(err);
    throw err;
  }

  if (!definition || !_.isObject(definition)) {
    var err = new Error('Please pass a valid command definition!');
    debug(err);
    throw err;
  }

  this.tree = tree;

  this.definition = {
    correlationId: 'correlationId', // optional
    id: 'id',                       // optional
    name: 'name',                   // optional
//      aggregateId: 'aggregate.id',    // optional
//      context: 'context.name',        // optional
//      aggregate: 'aggregate.name',    // optional
    payload: 'payload'              // optional
//      revision: 'revision'            // optional
//      version: 'version',             // optional
//      meta: 'meta'                    // optional, if defined theses values will be copied to the notification (can be used to transport information like userId, etc..)
  };

  this.definition = _.defaults(definition, this.definition);
}
229985
def _processEvents():
    """"""
    global _mousel, _mousem, _mouser, _eventsflushed, _pushedEvents
    _eventsflushed = True
    events = _pushedEvents # get events from event.push
    _pushedEvents = [] # then clear the pushed events queue

    mouse = _ffi.new('TCOD_mouse_t *')
    libkey = _ffi.new('TCOD_key_t *')
    while 1:
        libevent = _lib.TCOD_sys_check_for_event(_lib.TCOD_EVENT_ANY, libkey, mouse)
        if not libevent: # no more events from libtcod
            break

        #if mouse.dx or mouse.dy:
        if libevent & _lib.TCOD_EVENT_MOUSE_MOVE:
            events.append(MouseMotion((mouse.x, mouse.y),
                                      (mouse.cx, mouse.cy),
                                      (mouse.dx, mouse.dy),
                                      (mouse.dcx, mouse.dcy)))

        mousepos = ((mouse.x, mouse.y), (mouse.cx, mouse.cy))

        for oldstate, newstate, released, button in \
            zip((_mousel, _mousem, _mouser),
                (mouse.lbutton, mouse.mbutton, mouse.rbutton),
                (mouse.lbutton_pressed, mouse.mbutton_pressed,
                 mouse.rbutton_pressed),
                (1, 2, 3)):
            if released:
                if not oldstate:
                    events.append(MouseDown(button, *mousepos))
                events.append(MouseUp(button, *mousepos))
                if newstate:
                    events.append(MouseDown(button, *mousepos))
            elif newstate and not oldstate:
                events.append(MouseDown(button, *mousepos))

        if mouse.wheel_up:
            events.append(MouseDown(4, *mousepos))
        if mouse.wheel_down:
            events.append(MouseDown(5, *mousepos))

        _mousel = mouse.lbutton
        _mousem = mouse.mbutton
        _mouser = mouse.rbutton

        if libkey.vk == _lib.TCODK_NONE:
            break
        if libkey.pressed:
            keyevent = KeyDown
        else:
            keyevent = KeyUp

        events.append(
            keyevent(
                libkey.vk,
                libkey.c.decode('ascii', errors='ignore'),
                _ffi.string(libkey.text).decode('utf-8'),
                libkey.shift,
                libkey.lalt,
                libkey.ralt,
                libkey.lctrl,
                libkey.rctrl,
                libkey.lmeta,
                libkey.rmeta,
                )
            )

    if _lib.TCOD_console_is_window_closed():
        events.append(Quit())

    _eventQueue.extend(events)
1061526
def PushEvent(self, event):
    
    event_string = event.GetAttributeValuesString()
    heap_values = (event.timestamp, event.timestamp_desc, event_string, event)
    heapq.heappush(self._heap, heap_values)