Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added processCreated section #195

Merged
merged 3 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,30 @@ 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**

```js
function handleProcessCreated() {
processCount++;
console.log(`Process count: ${processCount}`);
}
```

The `handleProcessCreated` function will now increment the `processCount` variable each time it's called.
Loading