realbasic-nug
[Top] [All Lists]

Re: Circular reference powers used for good?

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Circular reference powers used for good?
From: Guyren Howe <guyren at mac dot com>
Date: Mon, 31 Dec 2007 16:03:41 -0600
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <1F31400A-2192-40FA-B482-EAAD05F0C530 at oxalyn dot com>
On Dec 31, 2007, at 12:59 AM, Eric Williams wrote:

> I have a situation which, oddly enough, seems to call for a circular
> reference, and I wanted some feedback on whether it's a good idea or
> not.
>
> The app needs to send it self a slightly delayed message - say, after
> a few seconds. I'm planning to deploy a Timer that calls back to an
> object's HandleTimedAction method. It's possible that several of
> these little timers could be necessary at once, and I don't want to
> keep track of them if I don't have to.
>
> Can I set up the timer with a property "myself as Timer" to make sure
> it doesn't go out of scope? Then, in the Timer's Action event, I can
> set the myself property to nil and it should just evaporate after the
> event ends (because no other object will hold a reference to it).
>
> Does anybody see any problem with this approach? Incidentally, I'm
> considering the circular reference setup to avoid a potential stack
> overflow. :)

What you propose would work just fine.

Another possibility is to use a thread which delays itself on launch.  
The thread stays around even if all references to it are dropped,  
until it finishes running.


Regards,

Guyren G Howe
Relevant Logic LLC

guyren-at-relevantlogic.com ~ http://relevantlogic.com

REALbasic, PHP, Ruby/Rails, Python programming
PostgreSQL, MySQL database design and consulting
Technical writing and training


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>