FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Post new topic   Reply to topic     Forum Index -> Ares
View previous topic :: View next topic  
Author Message

Joined: 24 Jun 2004
Posts: 609
Location: Bay Area, CA

PostPosted: Tue Sep 20, 2005 12:17 pm    Post subject: Requests Reply with quote

I'm copying this from the D newsgroup as a reminder. Feel free to post any other requests or suggestions here as well.

James Dunne <james.jdunne@gmail.com>:
I would love it if Ares provided some mechanism to *guarantee*
destruction of objects on program termination, whether that termination
be abnormal or normal (phobos currently does not do this). This would
come in handy for classes which manage more than memory resources, and
which need some sort of guarantee of disposal on program termination.

I've put some thought into this myself and hacked up a Linux-only patch
to phobos to try to implement this (not released, since it's Linux only
at the moment):

I came up with a std module named 'std.disposable' which defines an
interface called 'IDisposable' (I hope that doesn't conflict with COM
interfaces...). This interface defines nothing more than a void
Dispose() method.

In order to have an object inheriting from the IDisposable interface be
Dispose()'d on program termination, I wrote a function in the
std.disposable module named 'void markForDisposal(IDisposable obj)'. In
the class's constructor (or an otherwise appropriate place), this
function would be called to put the object's reference on the list of
marked objects. Similarly a function named 'void
unmarkForDisposal(IDisposable obj)' would remove the object's reference
from the list of marked objects.

In internal/dmain2.d, I modified it so that signals would be caught with
a signal handler, which would in turn call a function that traverses the
marked object list, calling Dispose() on each object. The call per each
object would be wrapped in a try .. catch block so as to "nearly
guarantee" that all marked objects were attempted to be Dispose()'d.

I ran into a problem here (what I mean by 'nearly guarantee'), because I
couldn't get it to where I could guarantee progress when a Dispose()
method itself generates some nasty signal and would cause abnormal
program termination. This is akin to a signal handler generating a
signal itself. Admittedly, I didn't read too far into the Linux/POSIX
signal specifications to find out how to correctly reset the signal
handler from within the signal handler.

What do you think of getting this sort of functionality into Ares?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Ares All times are GMT - 6 Hours
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group