Returns a callback that schedules events for the future.

        Returned callback function will add an event of type event_type
        to a queue which will be checked the next time an event is requested.
508641
def scheduled_event_trigger(self, event_type):
        """"""
        def callback(when, **kwargs):
            self.queued_scheduled_events.append((when, event_type(when=when, **kwargs)))
        return callback
1246083
def refresh(self):
        
        try:
            if self._timeout_event:
                self._scheduler.cancel(self._timeout_event)

        # Timeout event has been popped from queue prematurely
        except exception.EventNotFound:
            pass

        # Ensure a new event is scheduled always
        finally:
            self._timeout_event = self._scheduler.event_later(
                                      self._timeout_seconds,
                                      ('_idle', {'seconds': self._timeout_seconds}))
781052
def register(self, event_type: str,
                 **data_detail: Any) -> Callable[[AsyncCallback], AsyncCallback]:
        """"""
        def decorator(func: AsyncCallback) -> AsyncCallback:
            self.add(func, event_type, **data_detail)
            return func
        return decorator
139282
def check_events(self):
        ''''''
        while self.event_count() > 0:
            event = self.get_event()
            for callback in self._callbacks:
                callback(event)
1183700
def submit(self, call, *args, **kwargs):
        
        future = StoredFuture(call, *args, **kwargs)
        self._queue.put(future)
        self._ensure_worker()
        return future
1044580
def add_events(self, **kwargs):
        """"""

        event_q = kwargs.get('event_queue')
        pri = kwargs.get('priority')
        if not event_q or not pri:
            return

        try:
            event_type = 'server.failure.recovery'
            payload = {}
            timestamp = time.ctime()
            data = (event_type, payload)
            event_q.put((pri, timestamp, data))
            LOG.debug('Added failure recovery event to the queue.')
        except Exception as exc:
            LOG.exception('Error: %(exc)s for event %(event)s',
                          {'exc': str(exc), 'event': event_type})
            raise exc
601516
def add_future(self, future, callback):
        
        assert is_future(future)
        callback = stack_context.wrap(callback)
        future.add_done_callback(
            lambda future: self.add_callback(callback, future))
1314868
public function checkForNewSchedulers()
    {
        $current = SchedulerRepo::all();

        foreach($this->getScheduledEvents() as $event) {
            if (count($current->where('mutex', $event['mutex'])) < 1) {
                $command = new SchedulerRepo;
                $command->fill($event);
                $command->save();
            }
        }
    }
138917
function(self, types, fn) {
		var type;
		var trigger = self.trigger;
		var event_args = {};
	
		// override trigger method
		self.trigger = function() {
			var type = arguments[0];
			if (types.indexOf(type) !== -1) {
				event_args[type] = arguments;
			} else {
				return trigger.apply(self, arguments);
			}
		};
	
		// invoke provided function
		fn.apply(self, []);
		self.trigger = trigger;
	
		// trigger queued events
		for (type in event_args) {
			if (event_args.hasOwnProperty(type)) {
				trigger.apply(self, event_args[type]);
			}
		}
	}
1330286
def events(self, from_dt=None, to_dt=None):
        
        self.refresh_client(from_dt, to_dt)
        return self.response['Event']
642448
public synchronized EventData[] getEvents(int event_type) {
        ArrayList<EventData> v = new ArrayList<EventData>();
        for (EventData event : events)
            if (event.event_type == event_type)
                v.add(event);
        EventData[] periodic = new EventData[v.size()];
        for (int i = 0; i < v.size(); i++) {
            periodic[i] = v.get(i);
            events.remove(v.get(i));
        }
        return periodic;
    }
340919
def reschedule(event)
            # Check promise is not resolved
            return if event.resolved?

            @critical.synchronize {
                # Remove the event from the scheduled list and ensure it is in the schedules set
                if @schedules.include?(event)
                    remove(event)
                else
                    @schedules << event
                end

                # optimal algorithm for inserting into an already sorted list
                Bisect.insort(@scheduled, event)

                # Update the timer
                check_timer
            }
        end
1036828
function bind (type, callback) {
        if (!events.has(type)) {
          throw new Error('Unknown event: ' + type);
        }

        if (typeof callback !== 'function') {
          throw new Error('Callback must be a function, instead got: ' + (typeof callback));
        }

        var eventsOfType = events.get(type, Immutable.List());

        if (!eventsOfType.includes(callback)) {
          events = events.set(type, eventsOfType.push(callback));
        }

        return self;
      }
289179
def register(self, event, fn):
        
        self._callbacks.setdefault(event, []).append(fn)
        return fn
877661
def __add_callback(self, type_, func, serialised_if_crud=True):
        """"""
        Validation.callable_check(func)
        with self.__callbacks:
            self.__callbacks[type_].append((func, serialised_if_crud))
1076284
def schedule(self, function, args=(), kwargs={}):
        
        self._check_pool_state()

        future = Future()
        payload = TaskPayload(function, args, kwargs)
        task = Task(next(self._task_counter), future, None, payload)

        self._context.task_queue.put(task)

        return future
80302
def on(event)
      EVENT_TYPES.include?(event) or (self.class.logger.error "Invalid event #{event}" and return)
      block_given? and @blocks[event] << Proc.new
    end