Pages: 1
  Print  
Author Topic: Threading  (Read 1750 times)
Offline (Male) Goombert
Posted on: August 02, 2014, 07:21:57 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
This is just a quick opinion topic I want to get you guys thoughts on some things.

First, script_thread should not automatically execute, like any other programming language we should be able to create the thread and then execute when want, so I propose the addition of the following function.
thread_start(threadid);

I would also like to propose syntax handling to allow inline threads like Java.
Code: (EDL) [Select]
thread_create() {
  show_message("Thread Running");
}.start();

// also the following
var thread = thread_create() {
  show_message("Thread Running");
}
thread_start(thread);
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Male) Josh @ Dreamland
Reply #1 Posted on: August 02, 2014, 08:05:11 PM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2958

View Profile Email
I don't like the idea of a new syntax for threads. The new parser supports anonymous functions. If it doesn't, it will briefly.

Code: (EDL) [Select]
function my_thread() {
  for (int i = 0; i < 10; ++i) {
    show_message("Thread Running");
    sleep(1000);
  }
  show_message("Thread Done");
}

var thread = thread_function(my_thread);

Basically, leave the syntax modifications to supporting dynamic functions in general. A thread_start, thread_join, and thread_signal will follow from there.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) Goombert
Reply #2 Posted on: August 02, 2014, 08:08:23 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
Alright that all sounds good to me, so I should just not worry about the additional thread functions right now?
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) Darkstar2
Reply #3 Posted on: August 02, 2014, 09:31:56 PM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
@Robert:

I like the idea.  I'd like the ability to use threading for loading big assets into the background whilst in an animated game menu or during a game, or animated load screen,
currently script thread in ENIGMA only works with show message, it is broken for everything else.
Logged
Offline (Male) Josh @ Dreamland
Reply #4 Posted on: August 03, 2014, 11:25:12 AM

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2958

View Profile Email
Worry about them all you like. I doubt you would have much luck implementing either of those right now.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) Goombert
Reply #5 Posted on: August 10, 2014, 11:50:13 PM

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3110

View Profile
Threading has been seriously revamped in my latest commit, I was able to fully implement the threading functions and the implementation now more correctly mirrors most thread API's. I also fixed existing bugs in the thread functions.
http://enigma-dev.org/docs/Wiki/Game_State_Functions
https://github.com/enigma-dev/enigma-dev/pull/788
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Pages: 1
  Print