Triggered on every event, waiting until all necessary events are collected
770064
function(arr, info) {
      if (typeof arr !== "undefined") {
        arr.push(info);
      }
      if (!triggered &&
          seeBoth(c1ProfileEvts, "userId") && seeBoth(c2ProfileEvts, "userId") &&
          seeBoth(c1StateEvts, "clientId") && seeBoth(c2StateEvts, "clientId")) {
        triggered = true;
        Promise.all([ c1.getUsers(), c2.getUsers(), c1.getClients(), c2.getClients() ]).then(function(ret) {
          expect(ret[0][c1State.userId]).toEqual(Helper.makeUserProfile(c1State.userId));
          expect(ret[0][c2State.userId]).toEqual(Helper.makeUserProfile(c2State.userId));
          expect(ret[1][c1State.userId]).toEqual(Helper.makeUserProfile(c1State.userId));
          expect(ret[1][c2State.userId]).toEqual(Helper.makeUserProfile(c2State.userId));
          expect(ret[2][c1State.clientId]).toEqual(Helper.makeClientState(c1State.userId, c1State.clientId, "ONLINE"));
          expect(ret[2][c2State.clientId]).toEqual(Helper.makeClientState(c2State.userId, c2State.clientId, "ONLINE"));
          expect(ret[3][c1State.clientId]).toEqual(Helper.makeClientState(c1State.userId, c1State.clientId, "ONLINE"));
          expect(ret[3][c2State.clientId]).toEqual(Helper.makeClientState(c2State.userId, c2State.clientId, "ONLINE"));
          return Promise.all([ c1.logout(), c2.logout() ]);
        }).then(done).catch(Helper.errHandler);
      }
    }
896009
def run_until_complete(self) -> None:
        ''''''

        Log.debug('running event loop until all tasks completed')
        self.terminate_on_finish = True
        asyncio.ensure_future(self.init())
        self.loop.run_forever()
        self.loop.close()
750194
function () {
            for (var i = 0, l = methods.length; i < l; i++) {
                this.evented(methods[i])
            }
        }
1026672
async def gather(self):
        
        if self.__state == 'new':
            self.__setState('gathering')
            await self._connection.gather_candidates()
            self.__setState('completed')
501404
function onsuccess(event) {
            // remember the db instance
            self.db = event.target.result;

            // storage is now possible
            self.store = true;

            // execute all pending operations
            while (self.waiting.length) {
                self.waiting.shift().call(self);
            }

            // we're done, fire the callback
            if (cb) {
                cb.call(self, self);
            }
        }
987843
def dispatch_events!
      loop do
        event = @event_queue.pop

        callbacks.each do |callback|
          Thread.new do
            callback.call event
          end
        end
      end
    end
526499
def dispatchEvent(self, event, *args):
        
        for callback in self.listeners[event]:
            yield callback(event, self, *args)
49683
def trigger(self):
        """"""
        if _debug: IOCB._debug("trigger(%d)", self.ioID)

        # if it's queued, remove it from its queue
        if self.ioQueue:
            if _debug: IOCB._debug("    - dequeue")
            self.ioQueue.remove(self)

        # if there's a timer, cancel it
        if self.ioTimeout:
            if _debug: IOCB._debug("    - cancel timeout")
            self.ioTimeout.suspend_task()

        # set the completion event
        self.ioComplete.set()
        if _debug: IOCB._debug("    - complete event set")

        # make the callback(s)
        for fn, args, kwargs in self.ioCallback:
            if _debug: IOCB._debug("    - callback fn: %r %r %r", fn, args, kwargs)
            fn(self, *args, **kwargs)
265473
def wait_for_event(event):
    
    f = Future()
    def ready():
        get_event_loop().remove_win32_handle(event)
        f.set_result(None)
    get_event_loop().add_win32_handle(event, ready)
    return f
374798
function(event) {
            var state = self.state();

            for ( var i in self._callbacks ) {
                self._callbacks[i].call(self._doc, event, state);
            }
        }
1004994
function Event() {
    SelectableItem.call(this, this /* modelItem */);
    this.guid_ = tr.b.GUID.allocate();
    this.selectionState = SelectionState.NONE;
    this.associatedAlerts = new tr.model.EventSet();
    this.info = undefined;
  }
875062
def async_update(self, event):
        
        self.update_attr(event.get('state', {}))
        super().async_update(event)
631583
def _polling_iteration(self):
		
		if self.__task is None:
			self.ready_event().set()
		elif self.__task.check_events() is True:
			self.ready_event().set()
			self.registry().task_finished(self)
312689
def on(hook_type, state_or_event_name = nil, async = nil, &callback)
      sync_exclusive do
        if state_or_event_name.nil?
          state_or_event_name = HookEvent.any_state_or_event(hook_type)
        end
        async = false if async.nil?
        ensure_valid_callback_name!(hook_type, state_or_event_name)
        callback.extend(Async) if async == :async
        hooks.register(hook_type, state_or_event_name, callback)
      end
    end
533297
function(event, id, msg) {
      var self = this;
      var events = self['_on' + event];

      // Loop through event store and fire all functions.
      for (var i=events.length-1; i>=0; i--) {
        // Only fire the listener if the correct ID is used.
        if (!events[i].id || events[i].id === id || event === 'load') {
          setTimeout(function(fn) {
            fn.call(this, id, msg);
          }.bind(self, events[i].fn), 0);

          // If this event was setup with `once`, remove it.
          if (events[i].once) {
            self.off(event, events[i].fn, events[i].id);
          }
        }
      }

      // Pass the event type into load queue so that it can continue stepping.
      self._loadQueue(event);

      return self;
    }
193107
def _trigger_event(self, event, *args, **kwargs):
        """"""
        run_async = kwargs.pop('run_async', False)
        if event in self.handlers:
            if run_async:
                return self.start_background_task(self.handlers[event], *args)
            else:
                try:
                    return self.handlers[event](*args)
                except:
                    self.logger.exception(event + ' handler error')
953894
def _wait_non_ressources(self, callback):
        """"""  # noqa: E501
        self.trigger = threading.Lock()
        self.was_ended = False
        self.trigger.acquire()
        self.trigger.acquire()
        if not self.was_ended:
            callback(self)