next steps for CPS
It's an open secret that I've some criticisms of async/await: ## Fear of Threads From the perspective of a newcomer who is looking to transfer existing knowledge or code from another language to Nim, or someone who has zero experience with concurrency in any language, I recommend threads. Here follows the first example from the `threads.nim` documentation. I tweaked the syntax a touch -- _it was written in 2011_ -- but that is all. ```nim import locks type Payload = tuple[a, b: int] var thr: array[4, Thread[Payload]] L: Lock proc threadFunc(interval: Payload) {.thread.} = for i in interval.a .. interval.b: withLock L: echo i initLock L for i in 0 .. thr.high: createThread(thr[i], threadFunc, (i*10, i*10+5)) joinThreads thr deinitLock L ``` Here's the compilation output: ``` $ nim c --gc:arc --define:danger --threads:on -f th.nim .....CC: stdlib_assertions.nim CC: stdlib_io.nim CC: stdlib_system.nim CC: stdlib_locks.nim CC: th.nim Hint: 22456 lines; 0.121s; 20.68MiB peakmem; Dangerous Release build; proj: /home/adavidoff/th.nim; out: /home/adavidoff/th [SuccessX] ``` Here's the codegen: ``` Language files blank comment code ------------------------------------------------------------------------------- C 5 57 54 3733 ``` The resulting binary is 52,472 bytes in size and links against: ``` -rwxr-xr-x. 1 root root 147232 Nov 2 22:20 /lib64
Posted by disruptek on Dec 3, 2020, 6:05 AM
Tags
Related issues
- struct's lifetime requirements can be bypassed via covariant field assignment
- Proposal to Reorganize the Moderation Team and Review Moderation Policies
- Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
- proposal: container/...: generic collection types
- Better Custom Endpoint BYOK
- A concrete policy for backward compatibility until Godot 5.0
Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments
github (Other)
struct's lifetime requirements can be bypassed via covariant field assignment
Proposal to Reorganize the Moderation Team and Review Moderation Policies
Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
proposal: container/...: generic collection types
Better Custom Endpoint BYOK
A concrete policy for backward compatibility until Godot 5.0
New MTP models not supported
Tracking: 429 / Capacity Issues
next steps for CPS
It's an open secret that I've some criticisms of async/await: ## Fear of Threads From the perspective of a newcomer who is looking to transfer existing knowledge or code from another language to Nim, or someone who has zero experience with concurrency in any language, I recommend threads. Here follows the first example from the `threads.nim` documentation. I tweaked the syntax a touch -- _it was written in 2011_ -- but that is all. ```nim import locks type Payload = tuple[a, b: int] var thr: array[4, Thread[Payload]] L: Lock proc threadFunc(interval: Payload) {.thread.} = for i in interval.a .. interval.b: withLock L: echo i initLock L for i in 0 .. thr.high: createThread(thr[i], threadFunc, (i*10, i*10+5)) joinThreads thr deinitLock L ``` Here's the compilation output: ``` $ nim c --gc:arc --define:danger --threads:on -f th.nim .....CC: stdlib_assertions.nim CC: stdlib_io.nim CC: stdlib_system.nim CC: stdlib_locks.nim CC: th.nim Hint: 22456 lines; 0.121s; 20.68MiB peakmem; Dangerous Release build; proj: /home/adavidoff/th.nim; out: /home/adavidoff/th [SuccessX] ``` Here's the codegen: ``` Language files blank comment code ------------------------------------------------------------------------------- C 5 57 54 3733 ``` The resulting binary is 52,472 bytes in size and links against: ``` -rwxr-xr-x. 1 root root 147232 Nov 2 22:20 /lib64
Comments (0)
No comments yet. Start the discussion.