Fink::Finally man page on Darwin

Man page or keyword search:  
man Server   23457 pages
apropos Keyword Search (all sections)
Output format
Darwin logo
[printable version]

Fink::Finally(3)	      Fink documentation	      Fink::Finally(3)

NAME
       Fink::Finally - An object that can be cleaned up safely.

DESCRIPTION
       Often an object wishes to release resources when it is destroyed.
       However, Perl's DESTROY has some problems which make it inappropriate
       to be used directly.

       A Fink::Finally object will not run in a fork (causing two runs). It
       will also not run twice in normal circumstances. Finally, it ensures
       that $@ and $? are not changed.

       Circular references should never include a Fink::Finally object. This
       will cause the object to clean up only during global destruction, when
       it cannot depend on any references to exist.

SYNOPSIS
	 package Fink::Finally::Subclass;
	 use base 'Fink::Finally';
	 sub initialize	       { ... }
	 sub finalize	       { ... }

	 package main;

	 # Explicit cleanup
	 my $explicit = Fink::Finally::Subclass->new(@args);
	 $explicit->cleanup;

	 # Implicit cleanup
	 {
	     my $implicit = Fink::Finally::Subclass->new(@args);
	     # automatically cleaned up when it goes out of scope
	 }

	 # Preventing cleanup
	 {
	     my $prevent = Fink::Finally::Subclass->new(@args);
	     $prevent->cancel_cleanup;
	     # will not be cleaned up
	 }

EXTERNAL INTERFACE
       new
	     my $finally = Fink::Finally::Subclass->new(...);

	   Construct an object which will clean up when it goes out of scope.

       cleanup
	     $finally->cleanup;

	   Explicitly cause this object to clean up. Clean up will not happen
	   again when the object leaves scope.

	   This method should rarely be overridden, subclasses are encouraged
	   to override &finalize instead.

       cancel_cleanup
	     $finally->cancel_cleanup;

	   Prevent this object from cleaning up.

SUBCLASSING
       These methods should generally not be called externally, but are useful
       for subclasses to override the functionality of Fink::Finally.

       initialize
	     sub initialize {
		 my ($self) = @_;
		 ...

		 $self->SUPER::initialize();
	     }

	   The Fink::Base initializer, automatically called when an object is
	   created with &new.

	   Subclasses are encouraged to override this method, but they must
	   call "$self-"SUPER::initialize()> if they intend cleanup to work.
	   It may be useful to call SUPER::initialize at the end of
	   initialize, to ensure that cleanup only occurs after setup.

       finalize
	     sub finalize {
		 my ($self) = @_;
		 $self->SUPER::finalize();

		 ...
	     }

	   The finalizer that performs the actual cleanup.

	   Subclasses should almost always override this method. The methods
	   &cleanup and DESTROY should rarely be overridden instead,
	   overriding them may make cleanup unsafe.

SIMPLE CLEANUP
       A subclass Fink::Finally::Simple is provided to make safe cleanup
       available when a subclass is overkill.

       new
	     my $finally = Fink::Finally::Simple->new($code);

	   Create a new simple cleanup object.

	   The code-ref $code will be called to clean up. It will be provided
	   with a ref to this object as its only argument.

Fink 0.36.3.1			  2013-12-30		      Fink::Finally(3)
[top]

List of man pages available for Darwin

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net