Compare commits

...

3 Commits

Author SHA1 Message Date
bcb7e97184 Update README.md 2020-01-26 10:41:12 -05:00
af88b2a054 Update README.md 2020-01-26 10:28:21 -05:00
05456fa25e updated rockspec 2020-01-26 10:25:22 -05:00
3 changed files with 221 additions and 50 deletions

View File

@ -1,16 +1,15 @@
# multi Version: 13.1.0 Bug fixes and a few features added (See changes.md) # multi Version: 14.0.0 Bug fixes and cool new features added (See changes.md)
Found an issue? Please [submit it](https://github.com/rayaman/multi/issues) and ill look into it!
Found an issue? Please submit it and ill look into it! My multitasking library for lua. It is a pure lua binding, if you ignore the integrations and the love2d compat. If you find any bugs or have any issues, please let me know.
My multitasking library for lua. It is a pure lua binding, if you ignore the integrations and the love2d compat. If you find any bugs or have any issues, please let me know . **If you don't see a table of contents try using the ReadMe.html file. It is easier to navigate than readme**</br>
INSTALLING INSTALLING
---------- ----------
Note: The latest version of Lua lanes is required if you want to make use of system threads on lua 5.1+. I will update the dependencies for Lua rocks since this library should work fine on lua 5.1+ You also need the lua-net library and the bin library. all installed automatically using luarocks. however you can do this manually if lanes and luasocket are installed. Links: Links to dependicies:
https://github.com/rayaman/bin [bin](https://github.com/rayaman/bin)
https://github.com/rayaman/multi [net](https://github.com/rayaman/net)
https://github.com/rayaman/net [lanes](https://github.com/LuaLanes/lanes)
To install copy the multi folder into your environment and you are good to go</br> To install copy the multi folder into your environment and you are good to go</br>
If you want to use the system threads, then you'll need to install lanes! If you want to use the system threads, then you'll need to install lanes!
@ -18,6 +17,8 @@ If you want to use the system threads, then you'll need to install lanes!
Because of a codependency in net libaray, if using the networkmanager you will need to install the net library sepertly Because of a codependency in net libaray, if using the networkmanager you will need to install the net library sepertly
Going forward I will include a Release zip for love2d. I do not know why I haven't done this yet Going forward I will include a Release zip for love2d. I do not know why I haven't done this yet
**The Network Manager rework is currently being worked on and the old version is not included in this version. It will be released in 15.0.0**
``` ```
luarocks install multi luarocks install multi
luarocks install lnet luarocks install lnet
@ -25,28 +26,27 @@ luarocks install lnet
Discord Discord
------- -------
For real-time assistance with my libraries! A place where you can ask questions and get help with any of my libraries. Also, you can request features and stuff there as well.</br> Have a question that you need asking? Or need realtime assistance? Feel free to join the discord!</br>
https://discord.gg/U8UspuA</br> https://discord.gg/U8UspuA</br>
Planned features/TODO Planned features/TODO
--------------------- ---------------------
- [ ] Finish Documentation - [ ] Finish Documentation
- [ ] Test for unknown bugs -- This is always going on - [ ] Network Parallelism rework
- [x] ~~Network Parallelism~~ This was fun, I have some more plans for this as well
Usage:</br> Usage:</br>
----- -----
```lua ```lua
-- Basic usage Alarms: Have been moved to the core of the library require("multi") would work as well local multi, thread = require("multi").init()
local multi = require("multi") -- gets the entire library mutli:newThread("Example",function()
alarm=multi:newAlarm(3) -- in seconds can go to .001 uses the built in os.clock() while true do
alarm:OnRing(function(a) thread.sleep(1)
print("3 Seconds have passed!") print("Hello!")
a:Reset(n) -- if n were nil it will reset back to 3, or it would reset to n seconds end
end) end)
multi:mainloop() -- the main loop of the program, multi:umanager() exists as well to allow integration in other loops Ex: love2d love.update function. More on this binding in the wiki! multi:mainloop()
``` ```
Known Bugs/Issues Known Bugs/Issues
----------------- -----------------
Currently no bugs that I know of :D Check the Issue tab for issues

View File

@ -12,220 +12,356 @@
<h1 id="changes"><a name="changes" href="#changes"></a>Changes</h1><p class="toc" style="undefined"></p><ul> <h1 id="changes"><a name="changes" href="#changes"></a>Changes</h1><p class="toc" style="undefined"></p><ul>
<li><ul> <li><ul>
<li><span class="title"> <li><span class="title">
<a href="#update-13.1.0-bug-fixes-and-features-added" title="Update 13.1.0 Bug fixes and features added">Update 13.1.0 Bug fixes and features added</a> <a href="#update-14.0.0-consistency,-additions-and-stability" title="Update 14.0.0 Consistency, Additions and Stability">Update 14.0.0 Consistency, Additions and Stability</a>
</span> </span>
<!--span class="number"> <!--span class="number">
0 0
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update-13.0.0-added-some-documentation,-and-some-new-features-too-check-it-out!" title="Update 13.0.0 Added some documentation, and some new features too check it out!">Update 13.0.0 Added some documentation, and some new features too check it out!</a> <a href="#update-13.1.0-bug-fixes-and-features-added" title="Update 13.1.0 Bug fixes and features added">Update 13.1.0 Bug fixes and features added</a>
</span> </span>
<!--span class="number"> <!--span class="number">
1 1
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update-12.2.2-time-for-some-more-bug-fixes!" title="Update 12.2.2 Time for some more bug fixes!">Update 12.2.2 Time for some more bug fixes!</a> <a href="#update-13.0.0-added-some-documentation,-and-some-new-features-too-check-it-out!" title="Update 13.0.0 Added some documentation, and some new features too check it out!">Update 13.0.0 Added some documentation, and some new features too check it out!</a>
</span> </span>
<!--span class="number"> <!--span class="number">
2 2
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update-12.2.1-time-for-some-bug-fixes!" title="Update 12.2.1 Time for some bug fixes!">Update 12.2.1 Time for some bug fixes!</a> <a href="#update-12.2.2-time-for-some-more-bug-fixes!" title="Update 12.2.2 Time for some more bug fixes!">Update 12.2.2 Time for some more bug fixes!</a>
</span> </span>
<!--span class="number"> <!--span class="number">
3 3
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update-12.2.0" title="Update 12.2.0">Update 12.2.0</a> <a href="#update-12.2.1-time-for-some-bug-fixes!" title="Update 12.2.1 Time for some bug fixes!">Update 12.2.1 Time for some bug fixes!</a>
</span> </span>
<!--span class="number"> <!--span class="number">
4 4
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update-12.1.0" title="Update 12.1.0">Update 12.1.0</a> <a href="#update-12.2.0" title="Update 12.2.0">Update 12.2.0</a>
</span> </span>
<!--span class="number"> <!--span class="number">
5 5
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-12.0.0-big-update-(lots-of-additions-some-changes)" title="Update: 12.0.0 Big update (Lots of additions some changes)">Update: 12.0.0 Big update (Lots of additions some changes)</a> <a href="#update-12.1.0" title="Update 12.1.0">Update 12.1.0</a>
</span> </span>
<!--span class="number"> <!--span class="number">
6 6
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.11.1" title="Update: 1.11.1">Update: 1.11.1</a> <a href="#update:-12.0.0-big-update-(lots-of-additions-some-changes)" title="Update: 12.0.0 Big update (Lots of additions some changes)">Update: 12.0.0 Big update (Lots of additions some changes)</a>
</span> </span>
<!--span class="number"> <!--span class="number">
7 7
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.11.0" title="Update: 1.11.0">Update: 1.11.0</a> <a href="#update:-1.11.1" title="Update: 1.11.1">Update: 1.11.1</a>
</span> </span>
<!--span class="number"> <!--span class="number">
8 8
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.10.0" title="Update: 1.10.0">Update: 1.10.0</a> <a href="#update:-1.11.0" title="Update: 1.11.0">Update: 1.11.0</a>
</span> </span>
<!--span class="number"> <!--span class="number">
9 9
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.9.2" title="Update: 1.9.2">Update: 1.9.2</a> <a href="#update:-1.10.0" title="Update: 1.10.0">Update: 1.10.0</a>
</span> </span>
<!--span class="number"> <!--span class="number">
10 10
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.9.1" title="Update: 1.9.1">Update: 1.9.1</a> <a href="#update:-1.9.2" title="Update: 1.9.2">Update: 1.9.2</a>
</span> </span>
<!--span class="number"> <!--span class="number">
11 11
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.9.0" title="Update: 1.9.0">Update: 1.9.0</a> <a href="#update:-1.9.1" title="Update: 1.9.1">Update: 1.9.1</a>
</span> </span>
<!--span class="number"> <!--span class="number">
12 12
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.8.7" title="Update: 1.8.7">Update: 1.8.7</a> <a href="#update:-1.9.0" title="Update: 1.9.0">Update: 1.9.0</a>
</span> </span>
<!--span class="number"> <!--span class="number">
13 13
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.8.6" title="Update: 1.8.6">Update: 1.8.6</a> <a href="#update:-1.8.7" title="Update: 1.8.7">Update: 1.8.7</a>
</span> </span>
<!--span class="number"> <!--span class="number">
14 14
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.8.5" title="Update: 1.8.5">Update: 1.8.5</a> <a href="#update:-1.8.6" title="Update: 1.8.6">Update: 1.8.6</a>
</span> </span>
<!--span class="number"> <!--span class="number">
15 15
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.8.4" title="Update: 1.8.4">Update: 1.8.4</a> <a href="#update:-1.8.5" title="Update: 1.8.5">Update: 1.8.5</a>
</span> </span>
<!--span class="number"> <!--span class="number">
16 16
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.8.3" title="Update: 1.8.3">Update: 1.8.3</a> <a href="#update:-1.8.4" title="Update: 1.8.4">Update: 1.8.4</a>
</span> </span>
<!--span class="number"> <!--span class="number">
17 17
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.8.2" title="Update: 1.8.2">Update: 1.8.2</a> <a href="#update:-1.8.3" title="Update: 1.8.3">Update: 1.8.3</a>
</span> </span>
<!--span class="number"> <!--span class="number">
18 18
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.8.1" title="Update: 1.8.1">Update: 1.8.1</a> <a href="#update:-1.8.2" title="Update: 1.8.2">Update: 1.8.2</a>
</span> </span>
<!--span class="number"> <!--span class="number">
19 19
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.7.6" title="Update: 1.7.6">Update: 1.7.6</a> <a href="#update:-1.8.1" title="Update: 1.8.1">Update: 1.8.1</a>
</span> </span>
<!--span class="number"> <!--span class="number">
20 20
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.7.5" title="Update: 1.7.5">Update: 1.7.5</a> <a href="#update:-1.7.6" title="Update: 1.7.6">Update: 1.7.6</a>
</span> </span>
<!--span class="number"> <!--span class="number">
21 21
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.7.4" title="Update: 1.7.4">Update: 1.7.4</a> <a href="#update:-1.7.5" title="Update: 1.7.5">Update: 1.7.5</a>
</span> </span>
<!--span class="number"> <!--span class="number">
22 22
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.7.3" title="Update: 1.7.3">Update: 1.7.3</a> <a href="#update:-1.7.4" title="Update: 1.7.4">Update: 1.7.4</a>
</span> </span>
<!--span class="number"> <!--span class="number">
23 23
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.7.2" title="Update: 1.7.2">Update: 1.7.2</a> <a href="#update:-1.7.3" title="Update: 1.7.3">Update: 1.7.3</a>
</span> </span>
<!--span class="number"> <!--span class="number">
24 24
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.7.1-bug-fixes-only" title="Update: 1.7.1 Bug Fixes Only">Update: 1.7.1 Bug Fixes Only</a> <a href="#update:-1.7.2" title="Update: 1.7.2">Update: 1.7.2</a>
</span> </span>
<!--span class="number"> <!--span class="number">
25 25
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.7.0" title="Update: 1.7.0">Update: 1.7.0</a> <a href="#update:-1.7.1-bug-fixes-only" title="Update: 1.7.1 Bug Fixes Only">Update: 1.7.1 Bug Fixes Only</a>
</span> </span>
<!--span class="number"> <!--span class="number">
26 26
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.6.0" title="Update: 1.6.0">Update: 1.6.0</a> <a href="#update:-1.7.0" title="Update: 1.7.0">Update: 1.7.0</a>
</span> </span>
<!--span class="number"> <!--span class="number">
27 27
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.5.0" title="Update: 1.5.0">Update: 1.5.0</a> <a href="#update:-1.6.0" title="Update: 1.6.0">Update: 1.6.0</a>
</span> </span>
<!--span class="number"> <!--span class="number">
28 28
</span--> </span-->
</li> </li>
<li><span class="title"> <li><span class="title">
<a href="#update:-1.4.1---first-public-release-of-the-library" title="Update: 1.4.1 - First Public release of the library">Update: 1.4.1 - First Public release of the library</a> <a href="#update:-1.5.0" title="Update: 1.5.0">Update: 1.5.0</a>
</span> </span>
<!--span class="number"> <!--span class="number">
29 29
</span--> </span-->
</li> </li>
<li><span class="title">
<a href="#update:-1.4.1---first-public-release-of-the-library" title="Update: 1.4.1 - First Public release of the library">Update: 1.4.1 - First Public release of the library</a>
</span>
<!--span class="number">
30
</span-->
</li>
</ul> </ul>
</li> </li>
</ul> </ul>
<p></p><h2 id="update-13.1.0-bug-fixes-and-features-added"><a name="update-13.1.0-bug-fixes-and-features-added" href="#update-13.1.0-bug-fixes-and-features-added"></a>Update 13.1.0 Bug fixes and features added</h2><p>Added: </p><ul> <p></p><h2 id="update-14.0.0-consistency,-additions-and-stability"><a name="update-14.0.0-consistency,-additions-and-stability" href="#update-14.0.0-consistency,-additions-and-stability"></a>Update 14.0.0 Consistency, Additions and Stability</h2><p>Added:</p><ul>
<li>multi.init() — Initlizes the library! Must be called for multiple files to have the same handle. Example below</li><li>thread.holdFor(NUMBER sec, FUNCTION condition) — Works like hold, but timesout when a certain amount of time has passed!</li><li>multi.hold(function or number) — Its back and better than ever! Normal multi objs without threading will all be halted where threads will still run. If within a thread continue using thread.hold() and thread.sleep()</li><li>thread.holdWithin(NUMBER; cycles,FUNCTION; condition) — Holds until the condition is met! If the number of cycles passed is equal to cycles, hold will return a timeout error</li><li>multi.holdFor(NUMBER; seconds,FUNCTION; condition) — Follows the same rules as multi.hold while mimicing the functionality of thread.holdWithin<br><strong>Note:</strong> when hold has a timeout the first argument will return nil and the second atgument will be TIMEOUT, if not timed out hold will return the values from the conditions</li><li>thread objects now have hooks that allow you to interact with it in more refined ways!<br>— tObj.OnDeath(self,status,returns[…]) — This is a connection that passes a reference to the self, the status, whether or not the thread ended or was killed, and the returns of the thread.<br>— tObj.OnError(self,error) — returns a reference to self and the error as a string<br><strong>Limitations:</strong> only 7 returns are possible! This was done because creating and destroying table objects are slow. (The way the scheduler works this would happen every cycle and thats no good) Instead I capture the return values from coroutine.resume into local variables and only allowed it to collect 7 max.</li><li>thread.run(function) — Can only be used within a thread, creates another thread that can do work, but automatically returns whatever from the run function — Use thread newfunctions for a more powerful version of thread.run()</li><li>thread:newFunction(FUNCTION; func)<br>— returns a function that gives you the option to wait or connect to the returns of the function.<br>— func().wait() — waits for the function to return works both within a thread and outside of one<br>— func().connect() — connects to the function finishing<br>— func() — If your function does not return anything you dont have to use wait or connect at all and the function will return instantly. You could also use wait() to hold until the function does it thing<br>— If the created function encounters an error, it will return nil, the error message!</li><li>special variable multi.NIL was added to allow error handling in threaded functions.<br>— multi.NIL can be used in to force a nil value when using thread.hold()</li><li>All functions created in the root of a thread are now converted to threaded functions, which allow for wait and connect features. <strong>Note:</strong> these functions are local to the function! And are only converted if they arent set as local! Otherwise the function</li><li>lanes threads can now have their priority set using: sThread.priority =<br>— thread.Priority_Core<br>— thread.Priority_High<br>— thread.Priority_Above_Normal<br>— thread.Priority_Normal<br>— thread.Priority_Below_Normal<br>— thread.Priority_Low<br>— thread.Priority_Idle</li><li>thread.hold() and multi.hold() now accept connections as an argument. See example below</li></ul><pre class="lua hljs"><code class="lua" data-origin="<pre><code class=&quot;lua&quot;>package.path = &quot;./?/init.lua;&quot;..package.path
local multi, thread = require(&quot;multi&quot;):init()
conn = multi:newConnection()
multi:newThread(function()
thread.hold(conn)
print(&quot;Connection Fired!!!&quot;)
end)
multi:newAlarm(3):OnRing(function()
conn:Fire()
end)
</code></pre>"><span class="hljs-built_in">package</span>.path = <span class="hljs-string">"./?/init.lua;"</span>..<span class="hljs-built_in">package</span>.path
<span class="hljs-keyword">local</span> multi, thread = <span class="hljs-built_in">require</span>(<span class="hljs-string">"multi"</span>):init()
conn = multi:newConnection()
multi:newThread(<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span></span>
thread.hold(conn)
<span class="hljs-built_in">print</span>(<span class="hljs-string">"Connection Fired!!!"</span>)
<span class="hljs-keyword">end</span>)
multi:newAlarm(<span class="hljs-number">3</span>):OnRing(<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span></span>
conn:Fire()
<span class="hljs-keyword">end</span>)
</code></pre><p>thread newFunction</p><pre class="lua hljs"><code class="lua" data-origin="<pre><code class=&quot;lua&quot;>func=thread:newFunction(function(...)
print(&quot;Function running...&quot;)
thread.sleep(1)
return {1,2,3},&quot;done&quot;
end)
multi:newThread(&quot;Test&quot;,function()
func().connect(function(...)
print(...)
end)
end)
----OUTPUT----
&amp;gt; Function running...
&amp;gt; table: 0x008cf340 done nil nil nil nil nil
</code></pre>">func=thread:newFunction(<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(...)</span></span>
<span class="hljs-built_in">print</span>(<span class="hljs-string">"Function running..."</span>)
thread.sleep(<span class="hljs-number">1</span>)
<span class="hljs-keyword">return</span> {<span class="hljs-number">1</span>,<span class="hljs-number">2</span>,<span class="hljs-number">3</span>},<span class="hljs-string">"done"</span>
<span class="hljs-keyword">end</span>)
multi:newThread(<span class="hljs-string">"Test"</span>,<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span></span>
func().connect(<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(...)</span></span>
<span class="hljs-built_in">print</span>(...)
<span class="hljs-keyword">end</span>)
<span class="hljs-keyword">end</span>)
<span class="hljs-comment">----OUTPUT----</span>
&gt; Function running...
&gt; <span class="hljs-built_in">table</span>: <span class="hljs-number">0x008cf340</span> done <span class="hljs-keyword">nil</span> <span class="hljs-keyword">nil</span> <span class="hljs-keyword">nil</span> <span class="hljs-keyword">nil</span> <span class="hljs-keyword">nil</span>
</code></pre><p>thread newFunction using auto convert</p><pre class="lua hljs"><code class="lua" data-origin="<pre><code class=&quot;lua&quot;>package.path = &quot;./?/init.lua;&quot; .. package.path
multi, thread = require(&quot;multi&quot;).init()
a=5
multi:newThread(&quot;Test&quot;,function()
function hmm() -- Auto converted into a threaded function
return &quot;Hello!&quot;,2
end
print(a)
a=10
print(hmm().wait())
end)
multi:newAlarm(3):OnRing(function()
print(a)
end)
print(hmm)
multi:mainloop()
-----OUTPUT-----
&amp;gt; nil
&amp;gt; 5
&amp;gt; Hello! 2 nil nil nil nil nil -- The way I manage function returns is by allocating them to predefined locals. Because I pass these values regardless they technically get passed even when they are nil. This choice was made to keep the creation of tables to capture arguments then using unpack to pass them on when processing is done
&amp;gt; 10
</code></pre>"><span class="hljs-built_in">package</span>.path = <span class="hljs-string">"./?/init.lua;"</span> .. <span class="hljs-built_in">package</span>.path
multi, thread = <span class="hljs-built_in">require</span>(<span class="hljs-string">"multi"</span>).init()
a=<span class="hljs-number">5</span>
multi:newThread(<span class="hljs-string">"Test"</span>,<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span></span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">hmm</span><span class="hljs-params">()</span></span> <span class="hljs-comment">-- Auto converted into a threaded function</span>
<span class="hljs-keyword">return</span> <span class="hljs-string">"Hello!"</span>,<span class="hljs-number">2</span>
<span class="hljs-keyword">end</span>
<span class="hljs-built_in">print</span>(a)
a=<span class="hljs-number">10</span>
<span class="hljs-built_in">print</span>(hmm().wait())
<span class="hljs-keyword">end</span>)
multi:newAlarm(<span class="hljs-number">3</span>):OnRing(<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span></span>
<span class="hljs-built_in">print</span>(a)
<span class="hljs-keyword">end</span>)
<span class="hljs-built_in">print</span>(hmm)
multi:mainloop()
<span class="hljs-comment">-----OUTPUT-----</span>
&gt; <span class="hljs-keyword">nil</span>
&gt; <span class="hljs-number">5</span>
&gt; Hello! <span class="hljs-number">2</span> <span class="hljs-keyword">nil</span> <span class="hljs-keyword">nil</span> <span class="hljs-keyword">nil</span> <span class="hljs-keyword">nil</span> <span class="hljs-keyword">nil</span> <span class="hljs-comment">-- The way I manage function returns is by allocating them to predefined locals. Because I pass these values regardless they technically get passed even when they are nil. This choice was made to keep the creation of tables to capture arguments then using unpack to pass them on when processing is done </span>
&gt; <span class="hljs-number">10</span>
</code></pre><p>Fixed:</p><ul>
<li>Connections had a preformance issue where they would create a non function when using connection.getConnection() of a non existing label.</li><li>An internal mismanagement of the threads scheduler was fixed. Now it should be quicker and free of bugs</li><li>Thread error management is the integrations was not properly implemented. This is now fixed</li></ul><p>Removed:</p><ul>
<li>multi:newWatcher() — No real use</li><li>multi:newCustomObject() — No real use</li></ul><p>Changed:</p><ul>
<li>Connections connect function can now chain connections<pre class="lua hljs"><code class="lua" data-origin="<pre><code class=&quot;lua&quot;> package.path = &quot;./?/init.lua;&quot;..package.path
local multi, thread = require(&quot;multi&quot;).init()
test = multi:newConnection()
test(function(a)
print(&quot;test 1&quot;,a.Temp)
a.Temp = &quot;No!&quot;
end,function(a)
print(&quot;test 2&quot;,a.Temp)
a.Temp = &quot;Maybe!&quot;
end,function(a)
print(&quot;test 3&quot;,a.Temp)
end)
test:Fire({Temp=&quot;Yes!&quot;})
</code></pre>"> <span class="hljs-built_in">package</span>.path = <span class="hljs-string">"./?/init.lua;"</span>..<span class="hljs-built_in">package</span>.path
<span class="hljs-keyword">local</span> multi, thread = <span class="hljs-built_in">require</span>(<span class="hljs-string">"multi"</span>).init()
test = multi:newConnection()
test(<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(a)</span></span>
<span class="hljs-built_in">print</span>(<span class="hljs-string">"test 1"</span>,a.Temp)
a.Temp = <span class="hljs-string">"No!"</span>
<span class="hljs-keyword">end</span>,<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(a)</span></span>
<span class="hljs-built_in">print</span>(<span class="hljs-string">"test 2"</span>,a.Temp)
a.Temp = <span class="hljs-string">"Maybe!"</span>
<span class="hljs-keyword">end</span>,<span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">(a)</span></span>
<span class="hljs-built_in">print</span>(<span class="hljs-string">"test 3"</span>,a.Temp)
<span class="hljs-keyword">end</span>)
test:Fire({Temp=<span class="hljs-string">"Yes!"</span>})
</code></pre>
</li><li>Ties in to the new function that has been added multi.init()<pre class="lua hljs"><code class="lua" data-origin="<pre><code class=&quot;lua&quot;>local multi, thread = require(&quot;multi&quot;).init() -- The require multi function still returns the multi object like before
</code></pre>"><span class="hljs-keyword">local</span> multi, thread = <span class="hljs-built_in">require</span>(<span class="hljs-string">"multi"</span>).init() <span class="hljs-comment">-- The require multi function still returns the multi object like before</span>
</code></pre>
</li><li>love/lanesManager system threading integration has been reworked. Faster and cleaner code! Consistant code as well</li></ul><p>Note: Using init allows you to get access to the thread handle. This was done because thread was modifying the global space as well as multi. I wanted to not modify the global space anymore.<br>internally most of your code can stay the same, you only need to change how the library is required. I do toy a bit with the global space, buy I use a variable name that is invalid as a variable name. The variable name is $multi. This is used internally to keep some records and maintain a clean space</p><p>Also when using intergrations things now look more consistant.</p><pre class="lua hljs"><code class="lua" data-origin="<pre><code class=&quot;lua&quot;>local multi, thread = require(&quot;multi&quot;).init()
local GLOBSL, THREAD = require(&quot;multi.integration.lanesManager&quot;).init() -- or whichever manager you are using
local nGLOBAL, nTHREAD = require(&quot;multi.intergration.networkManager).inti()
</code></pre>">local multi, thread = require("multi").init()
local GLOBSL, THREAD = require("multi.integration.lanesManager").init() -- or whichever manager you are using
local nGLOBAL, nTHREAD = require("multi.intergration.networkManager).inti()
</code></pre><p>Note: You can mix and match integrations together. You can create systemthreads within network threads, and you can also create cotoutine based threads within bothe network and system threads. This gives you quite a bit of flexibility to create something awesome.</p><p>Going forward:</p><ul>
<li>Finish the rework of the networkManager - It “works”, but there are packet losses that I cannot explain. I do not know what is causing this at all. Ill fix when I figure it out!</li><li>If all goes well, the future will contain quality of code features. Ill keep an eye out for bugs</li></ul><h2 id="update-13.1.0-bug-fixes-and-features-added"><a name="update-13.1.0-bug-fixes-and-features-added" href="#update-13.1.0-bug-fixes-and-features-added"></a>Update 13.1.0 Bug fixes and features added</h2><p>Added: </p><ul>
<li>Connections:Lock() — Prevents a connection object form being fired</li><li>Connections:Unlock() — Removes the restriction imposed by conn:Lock()</li><li>new fucntions added to the thread namespace<br>— thread.request(THREAD handle,STRING cmd,VARARGS args) — allows you to push thread requests from outside the running thread! Extremely powerful.<br>— thread.exec(FUNCTION func) — Allows you to push code to run within the thread execution block!</li><li>handle = multi:newThread() — now returns a thread handle to interact with the object outside fo the thread<br>— handle:Pause()<br>— handle:Resume()<br>— handle:Kill()</li></ul><p>Fixed:</p><ul> <li>Connections:Lock() — Prevents a connection object form being fired</li><li>Connections:Unlock() — Removes the restriction imposed by conn:Lock()</li><li>new fucntions added to the thread namespace<br>— thread.request(THREAD handle,STRING cmd,VARARGS args) — allows you to push thread requests from outside the running thread! Extremely powerful.<br>— thread.exec(FUNCTION func) — Allows you to push code to run within the thread execution block!</li><li>handle = multi:newThread() — now returns a thread handle to interact with the object outside fo the thread<br>— handle:Pause()<br>— handle:Resume()<br>— handle:Kill()</li></ul><p>Fixed:</p><ul>
<li>Minor bug with multi:newThread() in how names and functions were managed</li><li>Major bug with the system thread handler. Saw healthy threads as dead ones</li><li>Major bug the thread scheduler was seen creating a massive amount of event causing memory leaks and hard crashes! This has been fixed by changing how the scheduler opperates. </li><li>newSystemThread()s returned object now matches both the lanes and love2d in terms of methods that are usable. Error handling of System threads now behave the same across both love and lanes implementations.</li><li>looks like I found a typo, thread.yeild -&gt; thread.yield</li></ul><p>Changed: </p><ul> <li>Minor bug with multi:newThread() in how names and functions were managed</li><li>Major bug with the system thread handler. Saw healthy threads as dead ones</li><li>Major bug the thread scheduler was seen creating a massive amount of event causing memory leaks and hard crashes! This has been fixed by changing how the scheduler opperates. </li><li>newSystemThread()s returned object now matches both the lanes and love2d in terms of methods that are usable. Error handling of System threads now behave the same across both love and lanes implementations.</li><li>looks like I found a typo, thread.yeild -&gt; thread.yield</li></ul><p>Changed: </p><ul>
<li>getTasksDetails(“t”), the table varaiant, formats threads, and system threads in the same way that tasks are formatted. Please see below for the format of the task details</li><li>TID has been added to multi objects. They count up from 0 and no 2 objects will have the same number</li><li>thread.hold() — As part of the memory leaks that I had to fix thread.hold() is slightly different. This change shouldnt impact previous code at all, but thread.hold() can not only return at most 7 arguments!</li><li>You should notice some faster code execution from threads, the changes improve preformance of threads greatly. They are now much faster than before!</li><li>multi:threadloop() — No longer runs normal multi objects at all! The new change completely allows the multi objects to be seperated from the thread objects!</li><li>local multi, thread = require(“multi”) — Since coroutine based threading has seen a change to how it works, requring the multi library now returns the namespace for the threading interface as well. For now I will still inject into global the thread namespace, but in release 13.2.0 or 14.0.0 It will be removed!</li></ul><h1 id="tasks-details-table-format"><a name="tasks-details-table-format" href="#tasks-details-table-format"></a>Tasks Details Table format</h1><pre><code data-origin="<pre><code>{ <li>getTasksDetails(“t”), the table varaiant, formats threads, and system threads in the same way that tasks are formatted. Please see below for the format of the task details</li><li>TID has been added to multi objects. They count up from 0 and no 2 objects will have the same number</li><li>thread.hold() — As part of the memory leaks that I had to fix thread.hold() is slightly different. This change shouldnt impact previous code at all, but thread.hold() can not only return at most 7 arguments!</li><li>You should notice some faster code execution from threads, the changes improve preformance of threads greatly. They are now much faster than before!</li><li>multi:threadloop() — No longer runs normal multi objects at all! The new change completely allows the multi objects to be seperated from the thread objects!</li><li>local multi, thread = require(“multi”) — Since coroutine based threading has seen a change to how it works, requring the multi library now returns the namespace for the threading interface as well. For now I will still inject into global the thread namespace, but in release 13.2.0 or 14.0.0 It will be removed!</li></ul><h1 id="tasks-details-table-format"><a name="tasks-details-table-format" href="#tasks-details-table-format"></a>Tasks Details Table format</h1><pre><code data-origin="<pre><code>{

View File

@ -0,0 +1,35 @@
package = "multi"
version = "14.0-0"
source = {
url = "git://github.com/rayaman/multi.git",
tag = "v14.0.0",
}
description = {
summary = "Lua Multi tasking library",
detailed = [[
This library contains many methods for multi tasking. From simple side by side code using multi-objs, to using coroutine based Threads and System threads(When you have lua lanes installed or are using love2d)
]],
homepage = "https://github.com/rayaman/multi",
license = "MIT"
}
dependencies = {
"lua >= 5.1",
"bin",
"lanes",
}
build = {
type = "builtin",
modules = {
["multi"] = "multi/init.lua",
["multi.compat.love2d"] = "multi/compat/love2d.lua",
["multi.integration.lanesManager"] = "multi/integration/lanesManager/init.lua",
["multi.integration.lanesManager.extensions"] = "multi/integration/lanesManager/extensions.lua",
["multi.integration.lanesManager.threads"] = "multi/integration/lanesManager/threads.lua",
["multi.integration.loveManager"] = "multi/integration/loveManager/init.lua",
["multi.integration.loveManager.extensions"] = "multi/integration/loveManager/extensions.lua",
["multi.integration.loveManager.threads"] = "multi/integration/loveManager/threads.lua",
["multi.integration.luvitManager"] = "multi/integration/luvitManager.lua",
--["multi.integration.networkManager"] = "multi/integration/networkManager.lua",
["multi.integration.shared"] = "multi/integration/shared.lua"
}
}