Skip to content

Commit

Permalink
Fix README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasstrehle committed Sep 21, 2023
1 parent 9c8fa62 commit dae8dec
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 12 deletions.
Binary file modified .github/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Example: Threads

This repository demonstrates **Single-Threading** and **Multi-Threading**.
This repository demonstrates the concepts of **Single-Threading** and **Multi-Threading** based on [DATEX](https://datex.unyt.org) on the example of calculating the digits of PI and creating a [TOR vanity address](https://community.torproject.org/onion-services/advanced/vanity-addresses/).


## Installation
Expand All @@ -19,15 +19,15 @@ This repository demonstrates **Single-Threading** and **Multi-Threading**.

## Structure
This diagram outlines the UIX default project structure.
We split our code base in [back-end](https://unyt.org/glossary#back-end), [front-end](https://unyt.org/glossary#front-end), and commons folder.
```
.
└── example-website-screenshot/
├── common/
│ ├── compoments/
│ │ ├── MainPage.scss // Main style declaration
│ │ └── MainPage.tsx // Main component
│ └── Worker.ts // Worker
│ ├── PI-Worker.ts // Worker for PI calculation
│ └── TOR-Worker.ts // Worker for TOR address gen
├── frontend/
│ ├── entrypoint.css // Front-end style declaration
│ └── entrypoint.tsx // Front-end entrypoint
Expand All @@ -37,14 +37,13 @@ We split our code base in [back-end](https://unyt.org/glossary#back-end), [front

## Features
* Threading
* Multiple threads
* Disposing of threads

## Preview
<img src=".github/screenshot.png" width="400">


## Explanation
*TODO*

---

<sub>&copy; unyt 2023 • [unyt.org](https://unyt.org)</sub>
4 changes: 0 additions & 4 deletions common/Worker.ts → common/PI-Worker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export function heavyCalculation(x: number, y:number) {
return x + y
}
export const pi = $$('');
export function* generateDigitsOfPi() {
let q = 1n;
let r = 180n;
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions common/components/MainPage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
padding-bottom: 30px;
&>input {
flex: 1;
padding: 20px;
border-radius: 10px;
max-width: 300px;
background-color: transparent;
Expand Down
4 changes: 2 additions & 2 deletions common/components/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class MainPage extends UIX.BaseComponent {
return;
parent.classList.add("hidden");

const threads = await spawnThreads<typeof import('../TOR.ts')>(new Path('../TOR.ts'), 10);
const threads = await spawnThreads<typeof import('../TOR-Worker.ts')>(new Path('../TOR-Worker.ts'), 10);
const calculations = threads.map(thread => thread.generateVanityAddress(this.torAddress.value));
const result = await Promise.any(calculations);
console.log("Found address", result);
Expand All @@ -49,7 +49,7 @@ export class MainPage extends UIX.BaseComponent {
return;
parent.classList.add("hidden");

const thread = await spawnThread<typeof import('../Worker.ts')>(new Path('../Worker.ts'));
const thread = await spawnThread<typeof import('../PI-Worker.ts')>(new Path('../PI-Worker.ts'));
const pi = await thread.calculatePI(+this.inputPiDigits.value || 10);
parent.querySelector("section")!.prepend(<span>{pi}</span>)
parent.classList.remove("hidden");
Expand Down

0 comments on commit dae8dec

Please sign in to comment.