[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exceptions that pass continuations

From: Panicz Maciej Godek
Subject: Re: Exceptions that pass continuations
Date: Fri, 19 Jul 2013 15:52:30 +0200

2013/7/19 Thien-Thi Nguyen <address@hidden>
() Panicz Maciej Godek <address@hidden>
() Fri, 19 Jul 2013 12:39:55 +0200

   and the whole thing can be used as follows

   (let ((resources '()))
     (supply (((release-resource r)
                  (set! r (cons r resources))))
       (let ((r (allocate-resource)))
         (demand 'release-resource r)
         (do-something-constructive-with r)))
     (for-each release-resource resources))

   (of course, this makes little sense if the
   resource is released within the same
   procedure it is allocated, but if the release
   cannot be performed locally, it seems the
   right thing)

   I wonder whether this design pattern has ever
   been used before, or if there are any potential
   flaws with its application.

Maybe i'm missing something about this particular situation, but i
think generally, the open-use-close pattern in the presence of gc is
best handled by SMOBS and guardians.  The resource is "opened" on SMOB
construction, used for some time and then either explicitly "closed"
(and forgotten) or forgotten.  The guardian notes the state (still
open, already closed) of its objects and closes the ones that need it.

In this case, are OpenGL "lights" not amenable to wrapping as a SMOB?

I've been considering making new type for lights -- perhaps that would
be a little more introspective -- but it turned out more efficient to
represent them in straightforward manner as integers.
However, the thing with the lights is that they need to be disabled
explicitly -- otherwise the lights that are no longer needed would
still lit the scene until the garbage collector decides to disable them.

Of course, I could call gc explicitly, but that would result in too big
overhead (I have tried before to run gc after rendering each frame,
but the CPU usage grew considerably; now I call it after every 64
frames or so). I could also disable all the lights after the scene 
is rendered, requiring to initialize them again and again before
rendering a new frame. I think that it would do.

Also, I recently read an article about garbage collector in mobile
apps, and perhaps having some means to do without it would
be a nice option. Here's the link:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]