Pages: 1 2 »
  Print  
Author Topic: script threading does not work  (Read 2891 times)
Offline (Unknown gender) Darkstar2
Posted on: June 26, 2014, 03:01:52 PM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
Let's say I want to load some binary data in the background without the dreaded black screen freeze,
and having a loading and progress bar, it does not work.
Example script is write.

I tried thread = script_thread(write,1)
(passing value 1 to script write.
But it does not work.
Logged
Offline (Male) Goombert
Reply #1 Posted on: June 26, 2014, 10:46:15 PM

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

View Profile
I tested and can not reproduce your problems. I tested on Windows 8.1

I added the following script to my project.
Code: (EDL) [Select]
show_message(argument0);
Then I added an object with the following code for the create event.
Code: (EDL) [Select]
script_thread(scr_0, "From thread");
show_message("From object create event");

I placed it in a room and ran the game and it behaved as expected showing both messages asynchronously.

You can download the source for this here.
https://www.dropbox.com/s/iyz1hgxxhujzqst/threadarguments.gm81
« Last Edit: June 26, 2014, 10:50:09 PM by Robert B Colton » 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 #2 Posted on: June 26, 2014, 10:50:18 PM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
Does it work only for show message ?

What about binary file read ?
I tried calling a script that had binary read and it froze the entire game until the block was loaded and script finished.

Logged
Offline (Male) Goombert
Reply #3 Posted on: June 26, 2014, 10:52:55 PM

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

View Profile
You mean file_bin_* functions? Yeah I don't know if those work in threads because of mutual exclusion, but since they are most likely implemented using the standard library I see no reason for that, they should be working, but the issue is definitely not threads.
« Last Edit: June 27, 2014, 12:26:10 AM by Robert B Colton » 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) TheExDeus
Reply #4 Posted on: June 27, 2014, 05:07:56 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Everything should work in threads. If something doesn't because of things like race conditions, then you will get wrong results (or crashes), but it would still work asynchronously. So your problem is somewhere different probably. I will test.

edit: I just tested and I also have some problems with sprite loading. The data it loads is pure white (1,1,1,1) for every pixel when loading from a thread, but loads fine otherwise. It could be a problem with data locality, as it might not be allocated correctly outside the thread. Should be investigated. But it seems to be a problem with sprites function and it works with _bin function (as it returns data directly instead of in the background like resource functions do).

Darkstar2, remember that you cannot use local variables in threaded scripts. For example:
Code: (EDL) [Select]
//Create of object
a = 0;

//Script
a = file_text_read_real(...); //Object.a is still 0, because this a is local for the thread

//Correct script
obj_someObject.a = file_text_read_real(...) //Now you specify the variable correctly
So you must either specify the object, make the variable global or pass the object as an argument (you can do "argument0.a" and call it by "script_thread(script,self.id)".
« Last Edit: June 27, 2014, 05:27:24 AM by TheExDeus » Logged
Offline (Male) Goombert
Reply #5 Posted on: June 28, 2014, 02:09:48 PM

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

View Profile
In contrast with what Harri just said, the new compiler does support atomic types however.
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) edsquare
Reply #6 Posted on: June 28, 2014, 03:15:20 PM

Member
Location: The throne of ringworld
Joined: Apr 2014
Posts: 402

View Profile
In contrast with what Harri just said, the new compiler does support atomic types however.

What new compiler?
Logged
A child of five would understand this. Send someone to fetch a child of five.
Groucho Marx
Offline (Male) Goombert
Reply #7 Posted on: June 28, 2014, 05:07:03 PM

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

View Profile
JustDefineIt, or JDI, by JoshDreamland is the new compiler, and it can parse the Standard Template Library and allow use of vector and other collections. It also has the capability of compiler scripts essentially allowing var access functions and dynamic execution such as execute_string() only if the user wants it of course. The biggest feature is proper pretty printers, meaning it can properly export your code to JavaScript allowing us to do HTML5.
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) edsquare
Reply #8 Posted on: June 28, 2014, 05:32:24 PM

Member
Location: The throne of ringworld
Joined: Apr 2014
Posts: 402

View Profile
JustDefineIt, or JDI, by JoshDreamland is the new compiler, and it can parse the Standard Template Library and allow use of vector and other collections. It also has the capability of compiler scripts essentially allowing var access functions and dynamic execution such as execute_string() only if the user wants it of course. The biggest feature is proper pretty printers, meaning it can properly export your code to JavaScript allowing us to do HTML5.

You mean this?:
https://github.com/JoshDreamland/JustDefineIt/tree/master/src

Over a year without commits, is it finished?
Logged
A child of five would understand this. Send someone to fetch a child of five.
Groucho Marx
Offline (Male) Josh @ Dreamland
Reply #9 Posted on: June 28, 2014, 06:01:23 PM

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

View Profile Email
The newer commits are not in the master branch. There haven't been any in a while for a number of reasons both legal and related to my own indecision, but the newest is much more recent than a year.

JDI is a C++ parser and object definition framework; it powers the new compiler. The new compiler itself is in a branch of ENIGMA's repository.

My current task, which anyone is welcome to pick up, is modifying the lexers used in JDI so that ENIGMA can more easily extend them. I plugged JDI into ENIGMA a little prematurely last time, and the maintainability suffered for it. I'm trying to avoid repeats of this mistake.
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 (Unknown gender) TheExDeus
Reply #10 Posted on: June 29, 2014, 07:11:35 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Quote
In contrast with what Harri just said, the new compiler does support atomic types however.
How is that "in contrast" when I didn't even mention atomic types? I didn't mention anything tied to compiler. I mentioned that in my test sprite_add indeed doesn't seem to work correctly in threads.

edit: Josh, what "legal reason" you are talking about? Something to do with google? Like if you work on ENIGMA your 1 day off, then they own it? :)
« Last Edit: June 29, 2014, 07:27:55 AM by TheExDeus » Logged
Offline (Unknown gender) Darkstar2
Reply #11 Posted on: June 29, 2014, 11:13:48 AM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
lol - most people are dying to ask Harri :P

It's probably some exclusivity thing, :P but given ENIGMA is a FREE project that would be doubtful, or it could have something to do with a company starting with Y......... :P

Since this new compiler is just a mirage in the desert maybe we should stop referencing it, if it's not likely to happen at all anyway :P  This will only encourage more people to learn C++ and do the stuff they can't compile directly in C++ and wrap it in a function in the enigma space.

If that actually works that's what I will do anyway. :D
Now everyone can still have wet dreams about a new compiler.......but it's time to get back down to earth :D

Yeah basically when you work for such large scale companies they basically own your soul and even the air you breath. :D
Logged
Offline (Male) Josh @ Dreamland
Reply #12 Posted on: June 29, 2014, 12:19:11 PM

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

View Profile Email
I had to file some paperwork so that I am able to freely contribute code to this project. It's to make sure personal projects don't compete with existing Google products in a way that would cause a conflict of interest. Apparently the review board found that a massive game design platform was far enough from mainstream Google to not warrant concern, but they advise me to contact them again if ENIGMA grows closer into Google territory. I have no idea how this would happen, considering game design is an extremely inclusive field as it is. They probably just say that to everyone.
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 (Unknown gender) Darkstar2
Reply #13 Posted on: June 29, 2014, 12:22:12 PM
Member
Joined: Jan 2014
Posts: 1244

View Profile Email
I had to file some paperwork so that I am able to freely contribute code to this project. It's to make sure personal projects don't compete with existing Google products in a way that would cause a conflict of interest. Apparently the review board found that a massive game design platform was far enough from mainstream Google to not warrant concern, but they advise me to contact them again if ENIGMA grows closer into Google territory. I have no idea how this would happen, considering game design is an extremely inclusive field as it is. They probably just say that to everyone.

You know, say you decide to one day make ENIGMA a search engine instead.  :P  ;D ;D ;D
Logged
Offline (Male) Josh @ Dreamland
Reply #14 Posted on: June 30, 2014, 07:27:11 AM

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

View Profile Email
I forgot we maintained a search engine, for a minute, 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
Pages: 1 2 »
  Print