## How works love.threads?

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.
NoAim91
Prole
Posts: 38
Joined: Mon Feb 20, 2017 10:28 am
Location: Germany

### Re: How works love.threads?

@zorg: yeah, the print doesn´t work ... and it should not return 10, it should return 13.... I guess the output = c1:demand() takes the c1:push(input) befor the thread input = c1:demand() can take the variable.

bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

### Re: How works love.threads?

That's probably what happens. You can have the main thread wait until the message has been delivered by using supply instead of push. And of course make sure you do that after starting the thread.

NoAim91
Prole
Posts: 38
Joined: Mon Feb 20, 2017 10:28 am
Location: Germany

### Re: How works love.threads?

okay, I thought I could solve my problem with threads, but it doesn´t work.

My problem -> game freeze because the for loop is too big.

Code: Select all

main.lua

input = 10000

c1:push(input)
t:start(c1)

output = 0

end

function love.update(dt)

if not t:isRunning() and output == 0 then output = c1:demand()  print(output) end

end


Code: Select all

local c1 = ...

input = c1:demand()

function test(input)
a = {}
for i=1, input do
a[i] = {}
for j=1, input do
a[i][j] = 0
end
end
return a
end

output = test(input)
c1:push(output)

basicly it is not possible to create a table with 10.000 x 10.000 entrys with one for loop?! I ask this question because I like to create big procedural generated worlds with the love.math.noise function... But If I make a cut after 1000x1000 and go for the next 1000x1000 than my world gets a scar :-/

zorg
Party member
Posts: 3041
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

### Re: How works love.threads?

It's much more likely that you just deadlocked your program with both threads waiting for one another in some way.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

NoAim91
Prole
Posts: 38
Joined: Mon Feb 20, 2017 10:28 am
Location: Germany

### Re: How works love.threads?

@zorg: nope. The thread starts and the main thread should update itself while the thread is doing its thing ... its not directly waiting.

If I use 1.000 as input it works. The Table is created with 1000x1000 entrys. But If I choose 10.000 it dies.

However ... I could need something which prevents the freezing

### Who is online

Users browsing this forum: No registered users and 47 guests