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

Re: [soaplite] Forcefull destruction of objects without waiting for timeout.

Expand Messages
  • 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 1 of 3 , May 4, 2002
    • 0 Attachment
      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.