You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by peter royal <pr...@apache.org> on 2006/11/28 17:19:55 UTC
Re: svn commit: r479860 - in /mina/trunk/core/src/main/java/org/apache/mina/transport/socket/nio: SocketAcceptor.java SocketConnector.java SocketIoProcessor.java
On Nov 27, 2006, at 6:51 PM, trustin@apache.org wrote:
> + protected void finalize() throws Throwable
> + {
> + super.finalize();
> + try
> + {
> + selector.close();
> + }
> + catch( IOException e )
> + {
> + ExceptionMonitor.getInstance().exceptionCaught( e );
> + }
> + }
How about an explicit .close() or similarly-named method so its not
necessary to rely on finalization?
I'm against having finalization be the only way to have the selector
be closed, as it is bad practice to use finalizers as destructors.
-pete
--
proyal@apache.org - http://fotap.org/~osi
Re: svn commit: r479860 - in /mina/trunk/core/src/main/java/org/apache/mina/transport/socket/nio: SocketAcceptor.java SocketConnector.java SocketIoProcessor.java
Posted by Trustin Lee <tr...@gmail.com>.
On 11/29/06, peter royal <pr...@apache.org> wrote:
>
> On Nov 27, 2006, at 6:51 PM, trustin@apache.org wrote:
> > + protected void finalize() throws Throwable
> > + {
> > + super.finalize();
> > + try
> > + {
> > + selector.close();
> > + }
> > + catch( IOException e )
> > + {
> > + ExceptionMonitor.getInstance().exceptionCaught( e );
> > + }
> > + }
>
> How about an explicit .close() or similarly-named method so its not
> necessary to rely on finalization?
>
> I'm against having finalization be the only way to have the selector
> be closed, as it is bad practice to use finalizers as destructors.
I thought the side effect of finilizers is very small considering the number
of SocketIoProcessors and other worker threads that uses a Selector. They
will usually consume less than 10 file descriptors, so it shouldn't be a
problem for most applications. Providing an additional shutdown method
would be a great idea, too, and I was going to provide one. That's why I
checked in this code to only trunk. We can code a little bit more and
provide such a method to resolve DIRMINA-316 (
http://issues.apache.org/jira/browse/DIRMINA-316).
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41 4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4 455E 1C62 A7DC 0255 ECA6
Re: svn commit: r479860 - in /mina/trunk/core/src/main/java/org/apache/mina/transport/socket/nio: SocketAcceptor.java SocketConnector.java SocketIoProcessor.java
Posted by Maarten Bosteels <mb...@gmail.com>.
I agree.
Maarten
On 11/28/06, peter royal <pr...@apache.org> wrote:
>
> On Nov 27, 2006, at 6:51 PM, trustin@apache.org wrote:
> > + protected void finalize() throws Throwable
> > + {
> > + super.finalize();
> > + try
> > + {
> > + selector.close();
> > + }
> > + catch( IOException e )
> > + {
> > + ExceptionMonitor.getInstance().exceptionCaught( e );
> > + }
> > + }
>
> How about an explicit .close() or similarly-named method so its not
> necessary to rely on finalization?
>
> I'm against having finalization be the only way to have the selector
> be closed, as it is bad practice to use finalizers as destructors.
>
> -pete
>
>
> --
> proyal@apache.org - http://fotap.org/~osi
>
>
>
>
>
>