diff --git a/.github/screenshot.png b/.github/screenshot.png index 3f32451..f418f76 100644 Binary files a/.github/screenshot.png and b/.github/screenshot.png differ diff --git a/README.md b/README.md index 2960942..f2330a1 100644 --- a/README.md +++ b/README.md @@ -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 @@ -19,7 +19,6 @@ 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/ @@ -27,7 +26,8 @@ We split our code base in [back-end](https://unyt.org/glossary#back-end), [front │ ├── 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 @@ -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 -## Explanation -*TODO* - --- © unyt 2023 • [unyt.org](https://unyt.org) diff --git a/common/Worker.ts b/common/PI-Worker.ts similarity index 84% rename from common/Worker.ts rename to common/PI-Worker.ts index 03ff905..1fa291a 100644 --- a/common/Worker.ts +++ b/common/PI-Worker.ts @@ -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; diff --git a/common/TOR.ts b/common/TOR-Worker.ts similarity index 100% rename from common/TOR.ts rename to common/TOR-Worker.ts diff --git a/common/components/MainPage.scss b/common/components/MainPage.scss index 8703ff5..fe828c2 100644 --- a/common/components/MainPage.scss +++ b/common/components/MainPage.scss @@ -25,6 +25,7 @@ padding-bottom: 30px; &>input { flex: 1; + padding: 20px; border-radius: 10px; max-width: 300px; background-color: transparent; diff --git a/common/components/MainPage.tsx b/common/components/MainPage.tsx index 3a42d12..729b0fc 100644 --- a/common/components/MainPage.tsx +++ b/common/components/MainPage.tsx @@ -29,7 +29,7 @@ export class MainPage extends UIX.BaseComponent { return; parent.classList.add("hidden"); - const threads = await spawnThreads(new Path('../TOR.ts'), 10); + const threads = await spawnThreads(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); @@ -49,7 +49,7 @@ export class MainPage extends UIX.BaseComponent { return; parent.classList.add("hidden"); - const thread = await spawnThread(new Path('../Worker.ts')); + const thread = await spawnThread(new Path('../PI-Worker.ts')); const pi = await thread.calculatePI(+this.inputPiDigits.value || 10); parent.querySelector("section")!.prepend({pi}) parent.classList.remove("hidden");