This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
wilcomega's profile picture

Multitasking API v0.1

Started by wilcomega, 15 August 2012 - 08:18 AM
wilcomega #1
Posted 15 August 2012 - 10:18 AM
Hello everyone. i just made a multitasking API a few days ago. it works fine for the most part( i havent found any bugs )
with the multitasking api you can run programs or functions on the background. i am working on a version that you can switch between programs with keys( maybe like crtl+tab? ) the game freezes when you switch to another one. the current version is made to be intergrated in an OS. of cource you can use it your own but i havent found much use for it.

if you are going to sell this on a server or just post it randomly on the internet i am fine with that but i WANT credits for the multitasking API
that was rule number 1 the second rule is that you should never run an program on the background that is printing stuff out. if it does its going to mess the screen up.

here is the code: http://pastebin.com/2yYLywGK
and if you just want to have the pastebin code:

pastebin get 2yYLywGK multitask

if you want the user control program( no credits needed, status and terminate not working ):
the source code: http://pastebin.com/KZA7NR4P
and the pastebin command:

pastebin get KZA7NR4P proces

how to use:
if you want to start the shell as main thread then just do the following

proces start
multitask.start( true )
the first argument on multitask.start( ) is if you want to start the shell
proces start does the same but it uses the userfriendly control program
a list of other functions in the API:

multitask.run( ) --dont use this guy, if you want to use it you have to know what you are doing
multitask.fileToFunction( sFile ) --returns a function that runs the program you used as first argument
multitask.runShell( ) --basicly runs the shell
multitask.create( function ) --this creates a new thread that will be executed when calling run() you dont use it like this: create( helloWorld( ) ), but kile this: create( helloWord )
multitask.runProgram( sFile ) --this uses the fileToFunction function to create a thread out of a file
multitask.start( bStartShell ) --starts running and starts shell depending on the first argument


let me know what you think in the comments and/or in the poll
ardera #2
Posted 15 August 2012 - 11:29 AM
Whats the difference between your api and the parallel API?

Its better to backup the term functions, because that are the central output functions
Pinkishu #3
Posted 15 August 2012 - 11:33 AM
Interesting I just made the same 3 days ago xD
Though I still have some bugs but mine lets me swtich between programs already
wilcomega #4
Posted 15 August 2012 - 12:51 PM
Interesting I just made the same 3 days ago xD
Though I still have some bugs but mine lets me swtich between programs already
nice :P/>/>
wilcomega #5
Posted 15 August 2012 - 12:52 PM
Whats the difference between your api and the parallel API?

Its better to backup the term functions, because that are the central output functions
in my api you can add threads at any time. where the parallel api you have to say what you want to run before hand
Sammich Lord #6
Posted 15 August 2012 - 01:10 PM
Hey there is not really documentation on how to use the API.
Can you update the post with a tutorial on how to use it?
wilcomega #7
Posted 15 August 2012 - 01:14 PM
Hey there is not really documentation on how to use the API.
Can you update the post with a tutorial on how to use it?
sure
Sammich Lord #8
Posted 15 August 2012 - 01:30 PM
Hey thanks for adding the tutorial very helpful!
I was just going to create something like this but I always say to myself: If something works fine, why not use it?
So I will give you full credit in my OS.
Sammich Lord #9
Posted 15 August 2012 - 01:43 PM
Hey I just found a bug:
In the process program on line 27 it is calling multitask.getStatus() but…
In the multitask API code it does not have the getStatus function.
wilcomega #10
Posted 15 August 2012 - 01:46 PM
i i am sorry that i forgot to mension that. i am working on that part. i could not get it to work so i left it out of there