Loading ...
Sorry, an error occurred while loading the content.
 

Forcefull destruction of objects without waiting for timeout.

Expand Messages
  • francis_reader
    Is there a way to forcefully destruct an object, rather that waiting for anykind of timeout. TIA Francis
    Message 1 of 3 , May 3, 2002
      Is there a way to forcefully destruct an object, rather that waiting
      for anykind of timeout.

      TIA Francis
    • Jim Dixon
      ... Simplest thing to do is to leave the scope in which the object was created. There must not be any live references to the object. -- Jim Dixon
      Message 2 of 3 , May 3, 2002
        On Fri, 3 May 2002, francis_reader wrote:

        > Is there a way to forcefully destruct an object, rather that waiting
        > for anykind of timeout.

        Simplest thing to do is to leave the scope in which the object was
        created. There must not be any live references to the object.

        --
        Jim Dixon jdd@... tel +44 117 982 0786 mobile +44 797 373 7881
        ---------- THAT'S A CHANGE OF ADDRESS: I'm no longer jdd@... --------
      • Duncan Cameron
        ... Do you mean destroying an object when you re using objects by reference with a SOAP::Lite server? When specifying the classes for OBR, you can also give a
        Message 3 of 3 , May 4, 2002
          On 2002-05-03 francis_reader wrote:
          >Is there a way to forcefully destruct an object, rather that waiting
          >for anykind of timeout.
          >
          >TIA Francis

          Do you mean destroying an object when you're using objects by reference with a
          SOAP::Lite server?

          When specifying the classes for OBR, you can also give a destroy subroutine that will be
          invoked to determine whether a particular instance should be garbage collected.
          See the pod under 'Objects by reference' and the code in Lite.pm around line 1898.

          Something like the following seems to work:

          In the server:

          my $daemon = SOAP::Transport::HTTP::Daemon
          -> new (LocalAddr => 'localhost', LocalPort => 80)
          -> objects_by_reference(\&My::A::destroy, 'My::A', \&My::B::destroy, 'My::B')
          -> dispatch_to('My::A', 'My::B')
          ;

          In My::A to mimic the default behaviour:

          sub destroy {
          print "In destroy $_[0] $_[2]\n";
          $_[1]-$_[$_[5] ? 5 : 4] > 600
          }

          The parameters to destroy() seem to be

          $_[0] number of instances already created of the class
          $_[1] the current time
          $_[2] the instance of the class
          $_[3] the class name
          $_[4] the time the instance was created
          $_[5] don't know!

          Return true to indicate that the instance should be garbage collected.

          You can them implement customised behaviour. Note that destroy() seems to be
          called only when a further instance of the class is to be created.

          Regards,
          Duncan Cameron
        Your message has been successfully submitted and would be delivered to recipients shortly.