🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.java
Article #437

Re: How to cleanup when a class is destroyed ?

#437
From: DavidL
Date: Thu, 12 Oct 2000 00:00
47 lines
1855 bytes
But what if I have a class something like:

class    port
{
    int        port_num;

    public        port (int i)
    {
        port_num = i;
    }

    public void    open ()
    {
        OsOpenPort (i);
    }

    public void    close ()
    {
        OsClosePort (i);
    }
}

Assume that this class is accessing some hardware port via the OS, maybe a
serial port.

You would certainly like that port to be available after the application is
terminated.

How do I ensure that the close() method is called ?
It is unreasonable to expect that the application will always call the
close() method, especially if there is an error.

David L :-)


"Dwayne Conyers" <dwacon@anti-spam.theglobe.com> wrote in message
news:%rnF5.41125$td5.6548300@news1.rdc2.pa.home.com...
> It isn't necessary in Java.
>
>
> --
>
> Weekly Web-Design Articles
> Now at Dwacon Software
> http://www.dwacon.com/Software
>
>
Technical Details
Message-ID: <39e62821$1@server.local>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <39e57bc3$1@server.local> <%rnF5.41125$td5.6548300@news1.rdc2.pa.home.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d6db,d25b87a070be9251
X-Google-Attributes: gid10d6db,public
From: "DavidL" <email.address@in.message>
Subject: Re: How to cleanup when a class is destroyed ?
Date: 2000/10/12
Message-ID: <39e62821$1@server.local>
X-Deja-AN: 680735776
References: <39e57bc3$1@server.local> <%rnF5.41125$td5.6548300@news1.rdc2.pa.home.com>
X-Original-NNTP-Posting-Host: 192.168.0.5
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
X-Complaints-To: news@bigpond.net.au
X-Trace: news-server.bigpond.net.au 971385236 144.132.179.174 (Fri, 13 Oct 2000 08:13:56 EST)
X-Authenticated-User: davidl
Organization: BigPond Internet Services (http://www.bigpond.net.au)
X-Original-Trace: 13 Oct 2000 08:07:45 +1100, 192.168.0.5
X-MSMail-Priority: Normal
NNTP-Posting-Date: Fri, 13 Oct 2000 08:13:56 EST
Newsgroups: aus.computers.java