Process an incoming event.

        Offers it to each module according to self.module_ordering,
        continuing to the next unless the module inhibits propagation.

        Returns True if a module inhibited propagation, otherwise False.
971339
def process_event(self, event, client, args, force_dispatch=False):
        
        if not self.running:
            _log.debug("Ignoring '%s' event - controller not running.", event)
            return

        # We keep a copy of the state of loaded modules before this event,
        # and restore it when we're done. This lets us handle events that
        # result in other events being dispatched in a graceful manner.
        old_loaded = self.loaded_on_this_event
        self.loaded_on_this_event = set(old_loaded or []) if not force_dispatch else set()

        try:
            _log.debug("Controller is dispatching '%s' event", event)
            for module_name in self.module_ordering:
                if module_name in self.loaded_on_this_event and not force_dispatch:
                    _log.debug("Not dispatching %s to '%s' because it was just "
                               "loaded (%r).", event, module_name,
                               self.loaded_on_this_event)
                    continue
                module = self.loaded_modules[module_name]
                if module.handle_event(event, client, args):
                    return True
        finally:
            self.loaded_on_this_event = old_loaded
574989
synchronized void nextEvent() {
        if (currentPosition > positionOfLastSync) {
            throw new IllegalStateException("Cannot advance past the last" +
                                                    " EV_SYN EV_SYN_REPORT 0");
        }
        currentPosition += eventStruct.getSize();
        if (MonocleSettings.settings.traceEventsVerbose && hasNextEvent()) {
            MonocleTrace.traceEvent("Processing %s [index=%d]",
                                    getEventDescription(), currentPosition);
        }
    }
468284
function isAllowed( $moduleName, $functionName, $connectType )
    {
        $eventArray = $this->fetchEvents();

        foreach ( array_keys( $eventArray ) as $key )
        {
            $eventType = $eventArray[$key]->attribute( 'workflow_type' );
            if ( !is_object( $eventType ) or !$eventType->isAllowed( $moduleName, $functionName, $connectType ) )
            {
                return false;
            }
        }

        return true;
    }
1002718
@Override public boolean process(Set<? extends TypeElement> types, RoundEnvironment env) {
    if (!env.processingOver()) {
      // Storing module names for later retrieval as the element instance is invalidated across
      // passes.
      for (Element e : env.getElementsAnnotatedWith(Module.class)) {
        if (!(e instanceof TypeElement)) {
          error("@Module applies to a type, " + e.getSimpleName() + " is a " + e.getKind(), e);
          continue;
        }
        delayedModuleNames.add(((TypeElement) e).getQualifiedName().toString());
      }
      return false;
    }

    Set<Element> modules = new LinkedHashSet<Element>();
    for (String moduleName : delayedModuleNames) {
      modules.add(elements().getTypeElement(moduleName));
    }

    for (Element element : modules) {
      Map<String, Object> annotation = null;
      try {
        annotation = getAnnotation(Module.class, element);
      } catch (CodeGenerationIncompleteException e) {
        continue; // skip this element. An up-stream compiler error is in play.
      }

      TypeElement moduleType = (TypeElement) element;
      if (annotation == null) {
        error("Missing @Module annotation.", moduleType);
        continue;
      }
      if (annotation.get("complete").equals(Boolean.TRUE)) {
        Map<String, Binding<?>> bindings;
        try {
          bindings = processCompleteModule(moduleType, false);
          new ProblemDetector().detectCircularDependencies(bindings.values());
        } catch (ModuleValidationException e) {
          error("Graph validation failed: " + e.getMessage(), e.source);
          continue;
        } catch (InvalidBindingException e) {
          error("Graph validation failed: " + e.getMessage(), elements().getTypeElement(e.type));
          continue;
        } catch (RuntimeException e) {
          if (ERROR_NAMES_TO_PROPAGATE.contains(e.getClass().getName())) {
            throw e;
          }
          error("Unknown error " + e.getClass().getName() + " thrown by javac in graph validation: "
              + e.getMessage(), moduleType);
          continue;
        }
        try {
          writeDotFile(moduleType, bindings);
        } catch (IOException e) {
          StringWriter sw = new StringWriter();
          e.printStackTrace(new PrintWriter(sw));
          processingEnv.getMessager()
              .printMessage(Diagnostic.Kind.WARNING,
                  "Graph visualization failed. Please report this as a bug.\n\n" + sw, moduleType);
        }
      }

      if (annotation.get("library").equals(Boolean.FALSE)) {
        Map<String, Binding<?>> bindings = processCompleteModule(moduleType, true);
        try {
          new ProblemDetector().detectUnusedBinding(bindings.values());
        } catch (IllegalStateException e) {
          error("Graph validation failed: " + e.getMessage(), moduleType);
        }
      }
    }
    return false;
  }
1011680
def process(self):
        
        self.modules.sort(key=lambda x: x.priority)

        for module in self.modules:
            transforms = module.transform(self.data)
            transforms.sort(key=lambda x: x.linenum, reverse=True)

            for transform in transforms:
                linenum = transform.linenum

                if isinstance(transform.data, basestring):
                    transform.data = [transform.data]

                if transform.oper == "prepend":
                    self.data[linenum:linenum] = transform.data

                elif transform.oper == "append":
                    self.data[linenum+1:linenum+1] = transform.data

                elif transform.oper == "swap":
                    self.data[linenum:linenum+1] = transform.data

                elif transform.oper == "drop":
                    self.data[linenum:linenum+1] = []

                elif transform.oper == "noop":
                    pass
27661
def timeout_queue_process(self):
        
        # process any items that need adding to the queue
        while self.timeout_add_queue:
            self.timeout_process_add_queue(*self.timeout_add_queue.popleft())
        now = time.time()
        due_timeouts = []
        # find any due timeouts
        for timeout in self.timeout_keys:
            if timeout > now:
                break
            due_timeouts.append(timeout)

        if due_timeouts:
            # process them
            for timeout in due_timeouts:
                modules = self.timeout_queue[timeout]
                # remove from the queue
                del self.timeout_queue[timeout]
                self.timeout_keys.remove(timeout)

                for module in modules:
                    # module no longer in queue
                    del self.timeout_queue_lookup[module]
                    # tell module to update
                    self.timeout_update_due.append(module)

            # when is next timeout due?
            try:
                self.timeout_due = self.timeout_keys[0]
            except IndexError:
                self.timeout_due = None

        # process any finished modules.
        # Now that the module has finished running it may have been marked to
        # be triggered again. This is most likely to happen when events are
        # being processed and the events are arriving much faster than the
        # module can handle them.  It is important as a module may handle
        # events but not trigger the module update.  If during the event the
        # module is due to update the update is not actioned but it needs to be
        # once the events have finished or else the module will no longer
        # continue to update.
        while self.timeout_finished:
            module_name = self.timeout_finished.popleft()
            self.timeout_running.discard(module_name)
            if module_name in self.timeout_missed:
                module = self.timeout_missed.pop(module_name)
                self.timeout_update_due.append(module)

        # run any modules that are due
        while self.timeout_update_due:
            module = self.timeout_update_due.popleft()
            module_name = getattr(module, "module_full_name", None)
            # if the module is running then we do not want to trigger it but
            # instead wait till it has finished running and then trigger
            if module_name and module_name in self.timeout_running:
                self.timeout_missed[module_name] = module
            else:
                self.timeout_running.add(module_name)
                Runner(module, self, module_name)

        # we return how long till we next need to process the timeout_queue
        if self.timeout_due is not None:
            return self.timeout_due - time.time()
1303455
@Override
    public boolean process(ContentEvent event) {
       
        if (event.isLastEvent() || 
                (instancesCount > 0 && instancesCount% this.sampleFrequency == 0)) {
            if (model.implementsMicroClusterer()) {

                Clustering clustering = model.getMicroClusteringResult();

                ClusteringResultContentEvent resultEvent = new ClusteringResultContentEvent(clustering, event.isLastEvent());

                this.outputStream.put(resultEvent);
            }
        }

        updateStats(event);
        return false;
    }
168355
def _process_module_order(parser, module, i, result):
    """"""
    #Some code might decide to use the fortpy module methods for general
    #development, ignore it since we know it will be present in the end.
    if module == "fortpy" or module == "fpy_auxiliary":
        return

    #See if the parser has alread loaded this module.
    if module not in parser.modules:
        parser.load_dependency(module, True, True, False)

    #It is possible that the parser couldn't find it, if so
    #we can't get a self-consistent ordering.
    if module in parser.modules:
        modneeds = parser.modules[module].needs
        for modn in modneeds:
            if modn not in result:
                #Since this module depends on the other, insert the other
                #above it in the list.
                result.insert(i, modn)
            else:
                x = result.index(modn)
                if x > i:
                    #We need to move this module higher up in the food chain
                    #because it is needed sooner.
                    result.remove(modn)
                    result.insert(i, modn)

            newi = result.index(modn)
            _process_module_order(parser, modn, newi, result)
    else:
        raise ValueError("unable to find module {}.".format(module))
1111472
def stop_all(self, run_order=-1):
		
		shutit_global.shutit_global_object.yield_to_draw()
		# sort them so they're stopped in reverse order
		for module_id in self.module_ids(rev=True):
			shutit_module_obj = self.shutit_map[module_id]
			if run_order == -1 or shutit_module_obj.run_order <= run_order:
				if self.is_installed(shutit_module_obj):
					if not shutit_module_obj.stop(self):
						self.fail('failed to stop: ' + module_id, shutit_pexpect_child=self.get_shutit_pexpect_session_from_id('target_child').shutit_pexpect_child)
421656
function processModules(item) {
  if (item.exports && !item._traced) {
    bootstrap(item, 'exports', item.filename);
    item._traced = true;
  }
  if (item.children) {
    item.children.map(processModules);
  }
}
250611
def _process_module_needs(self, modules):
        """"""
        result = list(modules)
        for i, module in enumerate(modules):
            #It is possible that the parser couldn't find it, if so
            #we can't create the executable!
            if module in self.module.parent.modules:
                modneeds = self.module.parent.modules[module].needs
                for modn in modneeds:
                    if modn not in result:
                        #Since this module depends on the other, insert the other
                        #above it in the list.
                        result.insert(i, modn)
                    else:
                        x = result.index(modn)
                        if x > i:
                            #We need to move this module higher up in the food chain
                            #because it is needed sooner.
                            result.remove(modn)
                            result.insert(i, modn)

                    newi = result.index(modn)
            else:
                raise ValueError("Unable to find module {}.".format(module))

        return result
347151
function dispatchEvent(event, handlers) {
    for (var i = (handlers.length - 1); i >= 0; i--) {
        if (event.isPropagationStopped()) {
            break;
        }
        var returnValue = handlers[i](event);
        if (returnValue === false) {
            event.stopPropagation();
            event.preventDefault();
        }
    }
}
64025
def trigger_event(self, module_name, event):
        
        if module_name:
            self._py3_wrapper.events_thread.process_event(module_name, event)
662932
public boolean process()
	{
		if (toProcess.size() <= 0)
			return false;

		BlockPos pos = toProcess.removeFirst();
		process(pos);
		if (onProcess != null)
			onProcess.accept(world, pos);

		return true;
	}
969376
def module_broadcast(m, broadcast_fn, *args, **kwargs):
    
    apply_leaf(m, lambda x: module_apply_broadcast(x, broadcast_fn, args, kwargs))
660925
function(eventName, eventHandler) {
      var stack = this.actual.data("events")[eventName];
      var i;
      for (i = 0; i < stack.length; i++) {
        if (stack[i].handler == eventHandler) {
          return true;
        }
      }
      return false;
    }
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