Re: Again. Resource deallocation in Common Lisp.
From: Lisptracker (lisptracker_at_mail.ru)
Date: 10/28/04
- Next message: Jacek Generowicz: "Re: Static vs Dynamic"
- Previous message: Peder O. Klingenberg: "Re: clisp on the rise?"
- In reply to: Lisptracker: "Again. Resource deallocation in Common Lisp."
- Next in thread: Christopher C. Stacy: "Re: Again. Resource deallocation in Common Lisp."
- Reply: Christopher C. Stacy: "Re: Again. Resource deallocation in Common Lisp."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Oct 2004 03:51:14 -0700
I am posting through Google and can not answer in time, so I post
reply to all incoming answers here. Many thanks to everyone who
replied on the topic.
"Neo-LISPer" <neo_lisper@yahoo.com> writes:
news:874qkfbjt5.fsf@yahoo.com...
> I'm not sure I understand the problem you described. You want
>
> 1. Sharing
> 2. Deterministic release of resources
> 3. Some sort of automation
>
> Correct? Does the C++ app you are porting from use boost::shared_ptr
> or equivalent then?
>
> If so, and you like this paradigm, you can just implement a "shared
> pointer" in Lisp - it is just a tuple of an object and a counter.
Yes, I think reference counting would be enough, but who will decrease
counter in case when owner object of slot is lost or owner of owner is
removed somehow ? In C++ this mechanism rely on lexical scope and
stack, if you destroy owner all member objects will be destroyed as
well, when you pass smart_ptr to function it is copied implicitly and
increased counter, when you done with smart_ptr and leave the function
body smart_ptr will be destroyed and counter is decreased. I don't
know How to implement such thing in Common Lisp, because of indefinite
extent, I can't follow all assignments and function applications. GC
finalizers (special free actions) as in Lispworks or CormanLisp can do
all bookkeeping for me, but if the program does not cons much, I don't
know when GC will run next time (and probably will never run).
>From: "Barry Margolin" <barmar@alum.mit.edu>
>Newsgroups: comp.lang.lisp
>Sent: Thursday, October 28, 2004 7:20 AM
>Subject: Re: Again. Resource deallocation in Common Lisp.
>The general problem is that there may not be a simple "dynamic scope
of
>execution" associated with the AVI object. In a complex application,
>there may be numerous references to the object, some of which are
>intended to persist past the termination of the code that initially
>opened it. So you don't want the resource to be reclaimed until all
of
>them have finished using the object.
Exactly! For example we operate by closures each of them is connected
to video stream. I want all connections to video streams to be droped
after I disposed "old" closure by "new" one, I can not wait until next
GC operation, and these closures are shared between objects. For
example It can be guaranteed that I've lost all references to "old"
objects but they all are part of complex object and when I remove that
object I do not want traverse through complex ownership hierarchy and
disconnect all sub-objects by hand.
"Christopher C. Stacy" <cstacy@news.dtpq.com> writes:
news:uhdof32te.fsf@news.dtpq.com...
> Barry Margolin <barmar@alum.mit.edu> writes:
> > The general problem is that there may not be a simple "dynamic
> > scope of execution" associated with the AVI object.
>
> The point where you allocate the resources is the same point where
> you deallocate them, regardless of how the containing object is
> passed around after that.
Problem is - you don't know WHEN to deallocate resource.
>We did manage in the past to write entire huge operating systems
>without any "finalizer" features in the language. (One technique
>was to create a seperate object, called a "resource" but really
>a resource pool, to manage a few kinds of things like this.)
Could you briefly explain idea please, how to manage resources with
resource pool ? I've come to exactly same conclusion (to use resource
managers), but I don't know how they will work (basic principle) ?
Best regards,
Lisptracker
- Next message: Jacek Generowicz: "Re: Static vs Dynamic"
- Previous message: Peder O. Klingenberg: "Re: clisp on the rise?"
- In reply to: Lisptracker: "Again. Resource deallocation in Common Lisp."
- Next in thread: Christopher C. Stacy: "Re: Again. Resource deallocation in Common Lisp."
- Reply: Christopher C. Stacy: "Re: Again. Resource deallocation in Common Lisp."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|