Removing 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.
Post Reply
Eversome
Prole
Posts: 5
Joined: Sat Jul 20, 2013 9:48 am
Location: Massachusetts

Removing Threads

Post by Eversome »

Hey, I was just wondering if there was some way to remove a thread after it finishes. I want to do this because:

(a.) Two threads can't have the same name. Unusable threads are a waste of space.
(b.) I can't use thread:start() to restart the thread until 0.9.0 ):
(c.) I hate the finished thread's guts and I want it to burn in a firey death.
wats a lau?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Removing Threads

Post by bartbes »

You need to wait on it for it to get cleaned up.
Eversome
Prole
Posts: 5
Joined: Sat Jul 20, 2013 9:48 am
Location: Massachusetts

Re: Removing Threads

Post by Eversome »

bartbes wrote:You need to wait on it for it to get cleaned up.
Alright, thanks for clearing that up. It wasn't exactly clear in the wiki ^^
wats a lau?
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Removing Threads

Post by T-Bone »

I guess garbage collection takes care of it? In that case, you have to make sure you don't have any references to it, just like any other object.
Eversome
Prole
Posts: 5
Joined: Sat Jul 20, 2013 9:48 am
Location: Massachusetts

Re: Removing Threads

Post by Eversome »

It seems that if I call :wait() on the finished thread and then :start() directly after, it restarts the thread rather than cleaning it up. Is this intended behavior?
wats a lau?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Removing Threads

Post by raidho36 »

Well, you kept the reference, so how did you expected thread to get cleaned?
Eversome
Prole
Posts: 5
Joined: Sat Jul 20, 2013 9:48 am
Location: Massachusetts

Re: Removing Threads

Post by Eversome »

Hmm. If I use return at the bottom of a thread, does it empty the thread's message pool?
wats a lau?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Removing Threads

Post by raidho36 »

To get rid of reference? Erm, no.

Code: Select all

mythread = nil
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Removing Threads

Post by bartbes »

Eversome wrote:Hmm. If I use return at the bottom of a thread, does it empty the thread's message pool?
It doesn't. There's an implicit return anyway. That said, when the thread object is garbage collected, then it will destroy the messages with it.
Post Reply

Who is online

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