Skip to content

Commit

Permalink
Added processCreated section
Browse files Browse the repository at this point in the history
  • Loading branch information
AtibQur committed Dec 7, 2024
1 parent c7d4fc4 commit e34534a
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,32 @@ if (cx) {

This example demonstrates how to register callbacks for CPU activity, disk activity, and disk latency. The CPU and disk activity callbacks log the current state (either "ready" or "busy") to the console, while the disk latency callback logs the latency of the last downloaded disk block.
Additionally, the simulated events are generated for testing purposes, allowing you to see output for all three types of activity.

### `processCreated` Event

The `processCreated` event is triggered by the **CheerpX engine** whenever a native process is created. This includes actions such as running a command within the WebVM terminal. The event provides a mechanism to track the number of processes created during the session.

**How it works**

Here's how the `processCreated` event is utilized in the code:

1. **Callback Registration:**

During the initialization of the CheerpX environment, the event is registered with the callback `handleProcessCreated`.

```js
cx.registerCallback("processCreated", handleProcessCreated);
```

2. **Callback implementation**

The `handleProcessCreated` function increments a `processCount` variable and triggers a callback if one is set via the processCallback function.

```js
function handleProcessCreated() {
processCount++;
if (processCallback) processCallback(processCount);
}
```

The purpose of the `processCreated` event is to maintain an up-to-date count of created processes. This information can be used to monitor system activity.

0 comments on commit e34534a

Please sign in to comment.