RemoteHandleControlBlock Class Reference

The RemoteHandleControlBlock is the equivalent of the std::shared_ptr's contol_block for a remote handle. More...

#include <ArmarXCore/core/util/distributed/RemoteHandle/RemoteHandleControlBlock.h>

+ Inheritance diagram for RemoteHandleControlBlock:

Classes

struct  ManagementData
 Returned by a call to RemoteHandleControlBlock::create. More...
 

Public Types

using clock = std::chrono::steady_clock
 

Public Member Functions

void decrementUseCount (const Ice::Current &=Ice::emptyCurrent) override
 decrements the useCount. More...
 
void forceDeletion ()
 Call this when you want to force the deletion of the managed object. More...
 
ClientSideRemoteHandleControlBlockBasePtr getClientSideRemoteHandleControlBlock (const Ice::Current &=Ice::emptyCurrent) override
 
Ice::ObjectPrx getManagedObjectProxy (const Ice::Current &=Ice::emptyCurrent) const override
 
Ice::Long getUseCount (const Ice::Current &=Ice::emptyCurrent) const override
 
void incrementUseCount (const Ice::Current &=Ice::emptyCurrent) override
 Increments the usecount. More...
 

Static Public Member Functions

template<class Deleter >
static ManagementData create (ArmarXManagerPtr manager, Ice::ObjectPrx managedObjectPrx, Deleter deleter)
 Creates a new RemoteHandleControlBlock. More...
 
static int64_t now ()
 

Friends

struct SharedRemoteHandleState
 

Detailed Description

The RemoteHandleControlBlock is the equivalent of the std::shared_ptr's contol_block for a remote handle.

It does reference counting and object deletion.

This class is created on server side and a ClientSideRemoteHandleControlBlock is send to the client. Only create the class by calling RemoteHandleControlBlock::create.

A direct pointer can be used to force the deletion of the managed object. The deletion has to be done by a passed deleter (it may hold the only pointer to the managed object or execute code to remove the object from some structure). The deleter should do any unregistering for the managed object (e.g. remove the object from from an ice object adapter)

a object may leak if a connection error stops the message send when a handle is deleted (this stops the usecount from reaching zero). a object may be deleted with handles still alive if: 1) the object's deletion was forced 2) a scenario equivalent to this: pc A has the object and sends a handle to B pc B has now the only handle pc B now sends the handle to pc C and delets the handle before C deserialized the object (this could be done via a broadcast) The handle is deserialized after the deletion timeout set via property (default 3 sec) has passed. This scenario is possible but should not happen on a stable LAN if ice objects are not keept in a serialized form for a longer period.

(for more info: RemoteHandle tutorial)

Definition at line 102 of file RemoteHandleControlBlock.h.

Member Typedef Documentation

◆ clock

using clock = std::chrono::steady_clock

Definition at line 106 of file RemoteHandleControlBlock.h.

Member Function Documentation

◆ create()

RemoteHandleControlBlock::ManagementData create ( ArmarXManagerPtr  manager,
Ice::ObjectPrx  managedObjectPrx,
Deleter  deleter 
)
static

Creates a new RemoteHandleControlBlock.

Parameters
objectAdapterThe adapter used to register the RemoteHandleControlBlock to ice.
managedObjectPrxA Proxy to the managed object.
deleterA functor cleaning up the managed object. (has to delete it and unregister it) The Functor may have the only pointer keeping the managed object alive.
Returns
A direct pointer to the created RemoteHandleControlBlock and the ClientSideRemoteHandleControlBlock keeping the managed object alive.

Definition at line 215 of file RemoteHandleControlBlock.h.

+ Here is the caller graph for this function:

◆ decrementUseCount()

void decrementUseCount ( const Ice::Current &  = Ice::emptyCurrent)
override

decrements the useCount.

DO NOT CALL IT. (except you have called incrementUseCount)

Definition at line 33 of file RemoteHandleControlBlock.cpp.

◆ forceDeletion()

void forceDeletion ( )
inline

Call this when you want to force the deletion of the managed object.

It will be deleted ignoring the usecount. This may be used to ensure the deletion of all objects created by yout server when shutting down. This may be necessary if a client's decrementUseCount was lost by the network.

Definition at line 157 of file RemoteHandleControlBlock.h.

◆ getClientSideRemoteHandleControlBlock()

ClientSideRemoteHandleControlBlockBasePtr getClientSideRemoteHandleControlBlock ( const Ice::Current &  = Ice::emptyCurrent)
override
Returns
A new ClientSideRemoteHandleControlBlock.

Definition at line 43 of file RemoteHandleControlBlock.cpp.

◆ getManagedObjectProxy()

Ice::ObjectPrx getManagedObjectProxy ( const Ice::Current &  = Ice::emptyCurrent) const
inlineoverride

Definition at line 200 of file RemoteHandleControlBlock.h.

◆ getUseCount()

Ice::Long getUseCount ( const Ice::Current &  = Ice::emptyCurrent) const
inlineoverride
Returns
Returns the current use count.

Definition at line 195 of file RemoteHandleControlBlock.h.

◆ incrementUseCount()

void incrementUseCount ( const Ice::Current &  = Ice::emptyCurrent)
inlineoverride

Increments the usecount.

DO NOT CALL IT. (if you do, you are responsible to call decrementUseCount!)

Definition at line 190 of file RemoteHandleControlBlock.h.

◆ now()

static int64_t now ( )
inlinestatic

Friends And Related Function Documentation

◆ SharedRemoteHandleState

friend struct SharedRemoteHandleState
friend

Definition at line 187 of file RemoteHandleControlBlock.h.


The documentation for this class was generated from the following files: