Notification when the CPU execution cap changes.

        in execution_cap of type int
            The new CPU execution cap value. (1-100)
356237
def on_cpu_execution_cap_change(self, execution_cap):
        
        if not isinstance(execution_cap, baseinteger):
            raise TypeError("execution_cap can only be an instance of type baseinteger")
        self._call("onCPUExecutionCapChange",
                     in_p=[execution_cap])
1191472
function(compute, newValue, oldValue, batchNum) {
            // Only trigger event when value has changed
            if (newValue !== oldValue) {
                can.batch.trigger(compute, batchNum ? {
                        type: "change",
                        batchNum: batchNum
                    } : 'change', [
                        newValue,
                        oldValue
                    ]);
            }
        }
919199
def should_execute(self):
        """"""
        return self.args.apply and (self.args.no_confirm or self.confirm_execution())
4281
private void estimateNextExecution() {
		synchronized (TIMER_LOCK) {
			if (fixedDelay) {
				scheduledExecutionTime = period + System.currentTimeMillis();
			} else {
				if (firstExecution == 0) {
					// save timestamp of first execution
					firstExecution = scheduledExecutionTime;
				}
				long now = System.currentTimeMillis();
				long executedTime = (numInvocations++ * period);
				scheduledExecutionTime = firstExecution + executedTime;
				if(logger.isDebugEnabled()) {
					logger.debug("next execution estimated to run at " + scheduledExecutionTime);
				}
				if(logger.isDebugEnabled()) {
					logger.debug("current time is " + now);
				}
			}
		}
	}
85857
protected function _cpuinfo()
    {
        if (CommonFunctions::executeProgram('pidin', 'info', $buf)
           && preg_match('/^Processor\d+: (.*)/m', $buf)) {
            $lines = preg_split("/\n/", $buf, -1, PREG_SPLIT_NO_EMPTY);
            foreach ($lines as $line) {
                if (preg_match('/^Processor\d+: (.+)/', $line, $proc)) {
                    $dev = new CpuDevice();
                    $dev->SetModel(trim($proc[1]));
                    if (preg_match('/(\d+)MHz/', $proc[1], $mhz)) {
                        $dev->setCpuSpeed($mhz[1]);
                    }
                    $this->sys->setCpus($dev);
                }
            }
        }
    }
198009
def _stop_cpulimit(self):
        

        if self._cpulimit_process and self._cpulimit_process.returncode is None:
            self._cpulimit_process.kill()
            try:
                self._process.wait(3)
            except subprocess.TimeoutExpired:
                log.error("Could not kill cpulimit process {}".format(self._cpulimit_process.pid))
404251
function(eventName, cpuNumber, pid, ts, eventBase) {
      var event = /type=(\d+) state=(\d) cpu_id=(\d+)/.exec(eventBase.details);
      if (!event)
        return false;

      var targetCpuNumber = parseInt(event[3]);
      var cpuState = parseInt(event[2]);
      this.cpuStateSlice(ts, targetCpuNumber, event[1], cpuState);
      return true;
    }
518023
def set_mem_per_proc(self, mem_mb):
        """"""
        super().set_mem_per_proc(mem_mb)
        self.qparams["mem_per_cpu"] = self.mem_per_proc
692929
def xlim_change_check(self, idx):
        ''''''
        if not self.xlim_pipe[1].poll():
            return
        xlim = self.xlim_pipe[1].recv()
        if xlim is None:
            return
        #print("recv: ", self.graph_num, xlim)
        if self.ax1 is not None and xlim != self.xlim:
            self.xlim = xlim
            self.fig.canvas.toolbar.push_current()
            #print("setting: ", self.graph_num, xlim)
            self.ax1.set_xlim(xlim)
            # trigger the timer, this allows us to setup a v slow animation,
            # which saves a lot of CPU
            self.ani.event_source._on_timer()
540283
def cpu_count() -> int:
    """"""
    if multiprocessing is None:
        return 1
    try:
        return multiprocessing.cpu_count()
    except NotImplementedError:
        pass
    try:
        return os.sysconf("SC_NPROCESSORS_CONF")
    except (AttributeError, ValueError):
        pass
    gen_log.error("Could not detect number of processors; assuming 1")
    return 1
301988
@Override
	protected int detectTotalCpuPercent() throws Exception {
		Process process = null;
		try {

			// Execute command
			String cmd;
			if (command == null || command.isEmpty()) {
				String os = System.getProperty("os.name").toLowerCase();
				if (os.indexOf("win") >= 0) {

					// Windows command to query the actual CPU usage
					cmd = "wmic cpu get loadpercentage";

				} else {

					// Linux command to query the actual CPU usage
					cmd = "top -b -n2 -p 1 | fgrep \"Cpu(s)\" | tail -1 | awk -F'id,' -v prefix=\"$prefix\" "
							+ "'{ split($1, vs, \",\"); v=vs[length(vs)]; sub(\"%\", \"\", v); printf \"%s%.1f%%\n\", prefix, 100 - v }'";
				}
			} else {
				cmd = command;
			}
			process = Runtime.getRuntime().exec(cmd);
			BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
			StringBuilder tmp = new StringBuilder();
			String line = "";
			while ((line = reader.readLine()) != null) {
				tmp.setLength(0);
				char[] chars = line.toCharArray();
				for (char c : chars) {
					if (Character.isDigit(c)) {
						tmp.append(c);
					}
					if (c == ',' || c == '.') {
						tmp.append('.');
					}
				}
				if (tmp.length() > 0) {
					try {
						return (int) Double.parseDouble(tmp.toString());
					} catch (Exception ignored) {
					}
				}
			}
		} finally {
			if (process != null) {
				try {
					process.destroy();
				} catch (Exception ignored) {
				}
			}
		}
		return 0;
	}
390018
public int getTotalCpuPercent() {
		if (invalidMonitor.get()) {
			return 0;
		}
		long now = System.currentTimeMillis();
		int cpu;
		synchronized (Monitor.class) {
			if (now - cpuDetectedAt > cacheTimeout) {
				try {
					cachedCPU = detectTotalCpuPercent();
				} catch (Throwable cause) {
					logger.info("Unable to detect CPU usage!", cause);
					invalidMonitor.set(true);
				}
				cpuDetectedAt = now;
			}
			cpu = cachedCPU;
		}
		return cpu;
	}
615473
protected void notifyBufferChange(char[] newData, int numChars) {
        synchronized(bufferChangeLoggers) {
            Iterator<BufferChangeLogger> iterator = bufferChangeLoggers.iterator();
            while (iterator.hasNext()) {
                iterator.next().bufferChanged(newData, numChars);
            }
        }
    }
52926
def display_callback(self, cpu_cycles, op_address, address, value):
        
        self.display.write_byte(cpu_cycles, op_address, address, value)
        return value
868439
function watchChanges(io, params) {
    const folder = process.cwd();
    return watch(folder, { recursive: true }, () => {
        emitInfo('changes detected. Recompiling...');
        io.sockets.emit('load');
        const start = new Date().getTime();
        executeWithParams(params)
            .tap(alerts => {
                const ellapsed = new Date().getTime() - start;
                emitSuccess(`wow! recompiled and executed in ${ellapsed}ms!`);
                io.sockets.emit('update', compileMarkdown(alerts));
            })
            .catch(err => {
                emitError(`hot compilation error, baby: ${err.message}`);
                io.sockets.emit('failure', err.stack);
            });
    });
}
1341682
def set_cpu_status(self, status):
        
        assert status in snap7.snap7types.cpu_statuses, 'unknown cpu state %s' % status
        logger.debug("setting cpu status to %s" % status)
        return self.library.Srv_SetCpuStatus(self.pointer, status)
368448
def _StatusUpdateThreadMain(self):
    """"""
    while self._status_update_active:
      # Make a local copy of the PIDs in case the dict is changed by
      # the main thread.
      for pid in list(self._process_information_per_pid.keys()):
        self._CheckStatusAnalysisProcess(pid)

      self._UpdateForemanProcessStatus()

      if self._status_update_callback:
        self._status_update_callback(self._processing_status)

      time.sleep(self._STATUS_UPDATE_INTERVAL)