Experimental Threading extension

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)
10 Likes

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

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

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

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

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

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.

Multithreading what, if I may ask?

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.

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

1 Like

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

2 Likes

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

Thanks. I need to do more testing first.

4 Likes

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

3 Likes

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

7 Likes