Experimental Threading extension

#1

Multi Threading
I have been playing with dmThread and I managed to get it working. See the attached project. I have tested on Windows only.

defold threads.zip (16.0 KB)

Updated 1


Threading example.zip (22.9 KB).

Update 2
Added support for modules.
Threading example 2.zip (5.6 KB)
You can add the extension to your project through bitbucket.
https://bitbucket.org/ronaal/defoldthreads/get/master.zip

Running modules is as simple as

local fname = "main/modulename.lua"
thread.run2(fname,  argument, "background_function", on_complete)
8 Likes

#2

I’m not really sure what the post title is referring to?
And, is this a question? Or an issue? Or a dev diary?

0 Likes

#3

The title “Clicking last row in console window” could refer to:

But @kiprono please elaborate on the contents of your post.

0 Likes

#4

Oops. my mistake.I did not change the title(I don’t know why it autofill an old issue I had with the editor). My first time posting.

2 Likes

#5

Ok, cool! Can you tell us a bit more about what the extension does? You mentioned it is based on dmThread?

0 Likes

#6

It’s for multi-threading. In the zip above I have included some sample project. I have tested it on Windows and it seems to work.

0 Likes

#7

Multithreading what, if I may ask?

0 Likes

#8

Say you have some heavy computations you need to do. You can either do it in the main thread or background thread. The extension above allows you to run the task in background. It runs lua code(for the task) in a background thread.
Perhaps I should upload a better example. Hope I am making sense.

0 Likes

#9

Note that our Lua context isn’t thread safe, so you need to do any Lua interaction on the calling thread.

1 Like

#10

Yes. The background thread use its own state(from lua_newstate()) to interpret the lua code pass to it.

2 Likes

#11

This looks cool and useful! You should formalize this project more (give it a nice name) and put it up on Github (look at other Defold extensions to see how this can be setup) like other extensions with a sample project to show how it would be useful well in a project.

4 Likes

#12

Thanks. I need to do more testing first.

4 Likes

#13

I will add it to github in the next few days.

3 Likes

#14

I finally added the extension to Bitbucket. Links and examples are in my first post.

5 Likes