magic.lambda.threading
15.2.0
See the version list below for details.
dotnet add package magic.lambda.threading --version 15.2.0
NuGet\Install-Package magic.lambda.threading -Version 15.2.0
<PackageReference Include="magic.lambda.threading" Version="15.2.0" />
paket add magic.lambda.threading --version 15.2.0
#r "nuget: magic.lambda.threading, 15.2.0"
// Install magic.lambda.threading as a Cake Addin #addin nuget:?package=magic.lambda.threading&version=15.2.0 // Install magic.lambda.threading as a Cake Tool #tool nuget:?package=magic.lambda.threading&version=15.2.0
Threading in Hyperlambda and Magic
Threading in software development implies doing multiple things concurrently, scheduling CPU time for each of your threads, creating the illusion of having your computer doing multiple times concurrently. This concept is often referred to as "multi tasking" and is crucial for any modern operating system, and/or programming language. Hyperlambda contains several multi tasking related slots.
[fork]
Forks the given lambda into a new thread of execution, using a thread from the thread pool. This slot is useful for creating "fire and forget" lambda objects, where you don't need to wait for the result of the execution before continuing executing the current scope.
fork
info.log:I was invoked from another thread
To understand how [fork] works, you can imagine your computer's CPU as a single river, running down hill, and at some point the river divides into two equally large rivers. This is referred to as "a fork". The analogy of the river becomes important for another reason, which is the understanding of that the total amount of water is still the same, it's only parted into two smaller rivers - Implying you cannot "do more" with multi tasking, you can only equally share the same amount of resources as you had before between two different tasks. Multi threading does not make your CPU faster, it only schedules your CPU's time on multiple things, doing these things concurrently. However, if you have multiple tasks where each individual task needs to wait for IO data, threading typically speeds up your application, since it can make multiple requests for IO simultaneously, and have other machines, and/or processes working in parallel.
[join]
Joins all child [fork] invocations, implying the slot will wait until all forks directly below it has finished executing, and automatically copy the result of the [fork] into the original node.
join
fork
http.get:"https://servergardens.com"
fork
http.get:"https://gaiasoul.com"
As an analogy for what occurs above, imagine the two rivers from our above [fork] analogy that forked from one larger river into two smaller rivers, for then again to join up and becoming one large river again further down.
[semaphore]
Creates a named semaphore, where only one thread will be allowed to evaluate the same semaphore at the same time. Notice, the semaphore to use is defined through its value, implying you can use the same semaphore multiple places, by using the same value of your [semaphore] invocation.
semaphore:foo-bar
/*
* Only one thread will be allowed entrance into this piece of
* code at the same time, ensuring synchronized access, for cases
* where you cannot allow more than one thread to enter at the
* same time.
*/
In the above semaphore "foo-bar" becomes the name of your semaphore. If you invoke [semaphore] in any other parts of your Hyperlambda code, with "foo-bar" as the value, only one of your lambda objects will be allowed to execute at the same time. This allows you to "synchronize access" to shared resources, where only one thread should be allowed to access the shared resource at the same time. Such shared resources might be for instance files, or other things shared between multiuple threads, where it's crucial that only one thread is allowed to access the shared resource at the same time.
[sleep]
This slot will sleep the current thread for x number of milliseconds, where x is an integer value, expected to be passed in as its main value.
// Sleeps the main thread for 1 second, or 1000 milliseconds.
sleep:1000
Notice - This slot is typically releasing the thread back to the operating system, implying as
the current thread is "sleeping", it will not be a blocking call, and require ZERO physical operating
system threads while it is sleeping. This is true because of Hyperlambda's 100% perfectly async
nature.
Project website
The source code for this repository can be found at github.com/polterguy/magic.lambda.threading, and you can provide feedback, provide bug reports, etc at the same place.
Quality gates
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- magic.lambda.logging (>= 15.2.0)
- magic.node.extensions (>= 15.2.0)
- magic.signals (>= 15.2.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on magic.lambda.threading:
Package | Downloads |
---|---|
magic.library
Helper project for Magic to wire up everything easily by simply adding one package, and invoking two simple methods. When using Magic, this is (probably) the only package you should actually add, since this package pulls in everything else you'll need automatically, and wires up everything sanely by default. To use package go to https://polterguy.github.io |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
17.2.0 | 414 | 1/22/2024 |
17.1.7 | 186 | 1/12/2024 |
17.1.6 | 151 | 1/11/2024 |
17.1.5 | 191 | 1/5/2024 |
17.0.1 | 184 | 1/1/2024 |
17.0.0 | 345 | 12/14/2023 |
16.11.5 | 319 | 11/12/2023 |
16.9.0 | 289 | 10/9/2023 |
16.7.0 | 544 | 7/11/2023 |
16.6.12 | 244 | 7/5/2023 |
16.6.11 | 194 | 7/5/2023 |
16.6.10 | 146 | 7/5/2023 |
16.4.1 | 269 | 7/2/2023 |
16.4.0 | 357 | 6/22/2023 |
16.3.1 | 290 | 6/7/2023 |
16.3.0 | 300 | 5/28/2023 |
16.1.9 | 585 | 4/30/2023 |
15.10.11 | 427 | 4/13/2023 |
15.9.1 | 549 | 3/27/2023 |
15.9.0 | 399 | 3/24/2023 |
15.8.2 | 463 | 3/20/2023 |
15.7.0 | 340 | 3/6/2023 |
15.5.0 | 1,500 | 1/28/2023 |
15.2.0 | 608 | 1/18/2023 |
15.1.0 | 1,080 | 12/28/2022 |
14.5.7 | 641 | 12/13/2022 |
14.5.5 | 748 | 12/6/2022 |
14.5.1 | 617 | 11/23/2022 |
14.5.0 | 555 | 11/18/2022 |
14.4.5 | 649 | 10/22/2022 |
14.4.1 | 690 | 10/22/2022 |
14.4.0 | 593 | 10/17/2022 |
14.3.1 | 1,203 | 9/12/2022 |
14.3.0 | 589 | 9/10/2022 |
14.1.3 | 855 | 8/7/2022 |
14.1.2 | 604 | 8/7/2022 |
14.1.1 | 606 | 8/7/2022 |
14.0.14 | 642 | 7/26/2022 |
14.0.12 | 611 | 7/24/2022 |
14.0.11 | 566 | 7/23/2022 |
14.0.10 | 596 | 7/23/2022 |
14.0.9 | 598 | 7/23/2022 |
14.0.8 | 673 | 7/17/2022 |
14.0.5 | 738 | 7/11/2022 |
14.0.4 | 700 | 7/6/2022 |
14.0.3 | 671 | 7/2/2022 |
14.0.2 | 592 | 7/2/2022 |
14.0.0 | 807 | 6/25/2022 |
13.4.0 | 2,008 | 5/31/2022 |
13.3.4 | 1,395 | 5/9/2022 |
13.3.0 | 888 | 5/1/2022 |
13.2.0 | 1,094 | 4/21/2022 |
13.1.0 | 948 | 4/7/2022 |
13.0.0 | 666 | 4/5/2022 |
11.0.5 | 1,343 | 3/2/2022 |
11.0.4 | 717 | 2/22/2022 |
11.0.3 | 714 | 2/9/2022 |
11.0.2 | 747 | 2/6/2022 |
11.0.1 | 711 | 2/5/2022 |
10.0.21 | 697 | 1/28/2022 |
10.0.20 | 712 | 1/27/2022 |
10.0.19 | 701 | 1/23/2022 |
10.0.18 | 677 | 1/17/2022 |
10.0.16 | 691 | 1/14/2022 |