Jump to content




Multitasking - rewritten!


  • You cannot reply to this topic
17 replies to this topic

#1 Konlab

  • Members
  • 595 posts
  • LocationKerbin

Posted 14 November 2015 - 05:57 PM

Download:
http://pastebin.com/9N7Jdhk0

I rewrote this and now it's a lot more cleaner and modular. (Not sure about performance) and has a working windowed object so you can actually use it for multitasking shells!

Examples (Usage):
Spoiler
Documentation:
(All functions use dot notation: system.init() etc.)
Threads:
Spoiler
Systems:
Spoiler

Changlelog
Spoiler


Old post:
Spoiler

Please report any bugs or unneccessary features found and please share your opinion!

Edited by Konlab, 13 June 2016 - 06:10 PM.


#2 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 20 November 2015 - 03:10 PM

Don't be discouraged. Some people say that a thread doesn't get many replies when the program is not buggy. Atleast that's what they tell me to console me no one replies to OmniOS. :P/>

#3 LDDestroier

  • Members
  • 1,095 posts
  • LocationACDC Town

Posted 20 November 2015 - 06:14 PM

Looks interesting, but I'm no OS designer. O and CraftOS works just fine for me.

I own Space Engineers too, and the planets are awesome! It does have some performance issues though, but not too bad (unless you have a not-fast computer). Also, good luck making spaceships on planets, what with gravity and all.

#4 Konlab

  • Members
  • 595 posts
  • LocationKerbin

Posted 21 November 2015 - 09:18 AM

View PostCreator, on 20 November 2015 - 03:10 PM, said:

Don't be discouraged. Some people say that a thread doesn't get many replies when the program is not buggy. Atleast that's what they tell me to console me no one replies to OmniOS. :P/>/>
Everything that uses windows is completly untested and will probably not work, so it's buggy

I am working on the documentation so it's atleast a little bit useable.

About planets: they are not working. My game crashes every time I place a planet

Edited by Konlab, 23 November 2015 - 06:05 PM.


#5 Konlab

  • Members
  • 595 posts
  • LocationKerbin

Posted 22 November 2015 - 06:07 PM

NEW UPDATE
new version: 20151122
Download:
http://pastebin.com/cEdQ4DM6
http://pastie.org/10574286
Details in main post, added documentation for pausable and advanced systems

Edited by Konlab, 23 November 2015 - 06:30 PM.


#6 Konlab

  • Members
  • 595 posts
  • LocationKerbin

Posted 23 November 2015 - 11:12 AM

New unstable version: http://pastie.org/10575736
Edit: version 20151122 is now on Backspace! (Identifier: "Multitask")
http://backspace.cf/...ippet/Multitask
http://www.computerc...r-an-app-store/

NEW UPDATE:
version 20151123 is here:
http://pastebin.com/2FCAC7qU
http://pastie.org/10576407
Details in main post!
I will also update multitask on backspace when it becomes possible ;)

Edited by Konlab, 23 November 2015 - 06:04 PM.


#7 Konlab

  • Members
  • 595 posts
  • LocationKerbin

Posted 24 November 2015 - 05:46 PM

NEW UPDATE:
version 20151124 is here and this is my record: update in three days in a row!
Includes optimization and more interesting features but has no backwards compatibility, please check the changelog, the changed function signatures are there.
http://pastebin.com/YbYQVA08
http://pastie.org/10578463
Please post your suggestions, opinion, bugs etc. below!

Edited by Konlab, 24 November 2015 - 08:26 PM.


#8 Konlab

  • Members
  • 595 posts
  • LocationKerbin

Posted 28 November 2015 - 06:19 PM

New update:
version 20151128
Please check the changelog section in the main post for more info

IMPORTANT!
If you are using the new version if you can please make sure to turn off type checking (change line 5 to local doTypeChecks = false) to speed up the library in average of 50%, only leave it on, if really neccessary!
I don't know why I didn't set it to false as default.

About speeds, it's completly unmeasurable, only sometimes with type checking on I can get results around ~0.1 second when having 100 threads in a CCThreadSystem

#9 Creeper9207

  • Members
  • 211 posts

Posted 08 February 2016 - 03:58 PM

is index like the index in the thread table?

#10 Konlab

  • Members
  • 595 posts
  • LocationKerbin

Posted 23 March 2016 - 07:30 PM

View PostCreeper9207, on 08 February 2016 - 03:58 PM, said:

is index like the index in the thread table?
Index is the index of the thread in the list of the threads.

#11 Konlab

  • Members
  • 595 posts
  • LocationKerbin

Posted 10 June 2016 - 10:12 AM

I rewrote it and it's now a lot more cleaner i think: http://pastebin.com/h3akBGna
also see here: http://pastebin.com/pvQuK1B2 is an example shell using the rewritten multitasking (nothing fancy but I tried to write understandable and not clean code (can't write clean code anyways) while writing this shell)

#12 Konlab

  • Members
  • 595 posts
  • LocationKerbin

Posted 13 June 2016 - 06:13 PM

Update! See main post!

Example usages (I am using these for debugging:)
http://pastebin.com/Vw4xtWfa - I updated myshell too
http://pastebin.com/un0NnRVm - Experimental multi window shell still very buggy and wip

#13 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 13 June 2016 - 11:19 PM

Don't beg for reputation points.

#14 unnamedcoder

  • Members
  • 23 posts

Posted 16 June 2016 - 05:43 PM

Isn't this why the parallel api exists?

#15 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 16 June 2016 - 05:51 PM

View Postunnamedcoder, on 16 June 2016 - 05:43 PM, said:

Isn't this why the parallel api exists?

This does a ton of stuff parallel doesn't. For example, assigning windows, killing threads, or adding more threads while running.

#16 RedWolfie

  • Members
  • 9 posts
  • LocationUSA

Posted 19 June 2016 - 03:33 PM

I dont see any yields or sleeps in the code, how do you keep it from just running away?

#17 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 20 June 2016 - 12:36 AM

The idea is that you use it in much the same manner as you would when calling the coroutine API functions directly. That means you need to yield for event data yourself, and you need to resume your coroutines yourself.

Best I can make out, what it does handle for you is window-switching. At least, I think that's the point of it.

#18 Konlab

  • Members
  • 595 posts
  • LocationKerbin

Posted 20 June 2016 - 02:31 PM

You yield and you continue it with the event,
example usage:
Runs two functions at the same time
function runTwo(f1, f2)
--#create a system and two threads, will just leave out this because you can see how it works in the main post

while true do
  system.resume(os.pullEvent())
end
end

Edited by Konlab, 20 June 2016 - 02:31 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users