Archived

This forum has been archived. Please start a new discussion on GitHub.

deactivate particular object

Is it possible to deactivate particalar object in object adapter? I have many objects in single object adaper and want to delete the object safely.

I expect to be able to write something like:

adapter->remove(object); // stop object method calls
object->deactivate(); // wait until all requests completed
delete object; // now can safely delete the object

By the way, may be "remove" call waits for the completion of the pending requests?

Best Regards
Alexander Ivanenko

Comments

  • bernard
    bernard Jupiter, FL
    Hi Alexander,

    You just need to remove your object (servant) from the object adapter, and nothing else:
      adapter->remove(objectID);
    

    Remember that your servant is a reference-counted object, and you should never call delete explicitly on it.

    When you "add" a servant to the object adapter, Ice inserts this servant in the Active Servant Map (ASM)
    and increases its refcount. When you remove the servant from the object adapter, Ice removes this servant from the ASM and releases this refcount. And when Ice dispatches a request on a servant it found in the ASM, it increments the refcount of this servant for the duration of the dispatch, to prevent the servant from being destroyed during such dispatch.

    Remove does not wait for requests to complete: it just removes the servant from the ASM.

    I hope this is clearer now.

    Best regards,
    Bernard
  • bernard wrote: »
    And when Ice dispatches a request on a servant it found in the ASM, it increments the refcount of this servant for the duration of the dispatch, to prevent the servant from being destroyed during such dispatch.

    Thank you very much! This is clear now.