Multiple threads from one file?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Astusvis
Prole
Posts: 33
Joined: Fri Aug 05, 2011 5:22 pm

Multiple threads from one file?

Post by Astusvis »

_
Last edited by Astusvis on Tue Oct 06, 2015 9:08 pm, edited 1 time in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Multiple threads from one file?

Post by bartbes »

That should work.
User avatar
Astusvis
Prole
Posts: 33
Joined: Fri Aug 05, 2011 5:22 pm

Re: Multiple threads from one file?

Post by Astusvis »

Is there a limit to the number of threads? Or a number I *shouldn't* exceed?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Multiple threads from one file?

Post by bartbes »

The limit depends on the running system, and is generally huge.
However, you should try keeping around as little threads as possible, because it's both wasteful to have them around and not use them, and synchronization etc will only have a negative effect.
Of course true parallel execution can only happen when the amount of threads is less than or equal to the amount of processor cores.
User avatar
Astusvis
Prole
Posts: 33
Joined: Fri Aug 05, 2011 5:22 pm

Re: Multiple threads from one file?

Post by Astusvis »

OK, now my having multiple threads make those threads corrupt the imagedata they are making >.>
Can anyone make sense of why?
Attachments
Mandelbrot DEV.zip
Read the code, it is just for debugging
(1.52 KiB) Downloaded 175 times
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Multiple threads from one file?

Post by Boolsheet »

ImageData manipulation is not thread safe in 0.7.2. It's fixed in 0.8.0.
You could save the pixel values to a table, generate a string with table.concat and push that to the other thread.

If you haven't seen the warning on Thread:kill yet, there's really no reason you should use it.
It disregards everything and terminates the thread. This is useless unless you have an emergency situation where the process has to stop immediately.
Shallow indentations.
User avatar
Astusvis
Prole
Posts: 33
Joined: Fri Aug 05, 2011 5:22 pm

Re: Multiple threads from one file?

Post by Astusvis »

Ok, I'll do that.
And yes I have seen the warnings, but for some reason I can't restart a thread without manually killing it first. I disregarded the warning since I am only killing it once it has finished.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Denver, CO
Contact:

Re: Multiple threads from one file?

Post by TechnoCat »

Astusvis wrote:Ok, I'll do that.
I disregarded the warning since I .....
Famous last words.
User avatar
Astusvis
Prole
Posts: 33
Joined: Fri Aug 05, 2011 5:22 pm

Re: Multiple threads from one file?

Post by Astusvis »

Sorry, do you have a problem with logic?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Multiple threads from one file?

Post by Robin »

Astusvis wrote:for some reason I can't restart a thread without manually killing it first.
Why would you want to restart a thread anyway? Can't you put the bulk of the code in a big loop instead?
Astusvis wrote:I disregarded the warning since I am only killing it once it has finished.
I'm not sure about the actual implementation details, but that might still cause problems with things not having a chance to be cleaned up properly.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: DTmg, Semrush [Bot] and 4 guests