love.thread.newThread

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.
Post Reply
User avatar
leiradel
Party member
Posts: 184
Joined: Thu Mar 11, 2010 3:40 am
Location: Lisbon, Portugal

love.thread.newThread

Post by leiradel »

I've read the threads documentation and there are two ways of creating a thread:

Code: Select all

thread = love.thread.newThread( name, file ) -- create a thread that runs the file source code
thread = love.thread.newThread( name, data ) -- ???
The only Data subtype in the Wiki is SoundData, so I wonder what the second form for creating a thread does?

Could we have support for creating threads from a function, assuming the second form doesn't do it? I.e.:

Code: Select all

local function im_running_free()
  -- do something cool while listening to Iron Maiden
end

local thread = love.thread.newThread( 'yeah', im_running_free )
The first form could be implemented in terms of it...

Cheers,

Andre
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: love.thread.newThread

Post by Robin »

leiradel wrote:I've read the threads documentation and there are two ways of creating a thread:

Code: Select all

thread = love.thread.newThread( name, file ) -- create a thread that runs the file source code
thread = love.thread.newThread( name, data ) -- ???
The only Data subtype in the Wiki is SoundData, so I wonder what the second form for creating a thread does?
data is a FileData here, it was the original version of newThread. I think FileData is undocumented, but it has been successfully used in the past.
Help us help you: attach a .love.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: love.thread.newThread

Post by bartbes »

The biggest con of running functions (except for it being hard :P) is that every thread is completely separated from the other thread, combining them in the same sourcefile would be a bit confusing to some/most.

Regarding data, well, in theory it could be any form of data, but most won't give you a useful result, love.filesystem.FileData will, however.
User avatar
leiradel
Party member
Posts: 184
Joined: Thu Mar 11, 2010 3:40 am
Location: Lisbon, Portugal

Re: love.thread.newThread

Post by leiradel »

Robin wrote:data is a FileData here, it was the original version of newThread. I think FileData is undocumented, but it has been successfully used in the past.
Ah, it's not listed in the Wiki page for Data as a subtype...
bartbes wrote:The biggest con of running functions (except for it being hard ) is that every thread is completely separated from the other thread, combining them in the same sourcefile would be a bit confusing to some/most.
Threads get their own Lua state then, right?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: love.thread.newThread

Post by bartbes »

leiradel wrote:Threads get their own Lua state then, right?
Yes.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 58 guests