POV-Ray : Newsgroups : povray.off-topic : Programming design question, related to GC : Re: Programming design question, related to GC Server Time
1 Oct 2024 07:18:55 EDT (-0400)
  Re: Programming design question, related to GC  
From: Warp
Date: 12 Apr 2008 18:59:00
Message: <48013eb3@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> So the code would be

> thisListener = weak_to_strong(listeners[i]);
> if (thisListener != null) listeners[i].doSomething();
> else listeners[i] = null;

  In theory it could happen that each time the GC takes a sweep,
that second line is being executed. (Yes, extremely unlikely for
that to happen each time, but theoretically possible.) Since that
second line is using a strong reference, the object is not destroyed?

  Also, I assume that the weak_to_strong() function must be locking
(ie. have mutual exclusion). Doesn't that make it slower than just
using a strong reference?

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.