28#include <condition_variable>
33#include <Ice/ObjectAdapter.h>
34#include <IceUtil/UUID.h>
36#include <ArmarXCore/interface/core/util/distributed/RemoteHandle/RemoteHandleControlBlock.h>
68 std::mutex stateMutex;
71 std::set<RemoteHandleControlBlockPtr> rhs;
72 std::chrono::milliseconds deletionDelay;
101 class RemoteHandleControlBlock :
virtual public RemoteHandleControlBlockInterface
104 using clock = std::chrono::steady_clock;
105 inline static int64_t
now();
126 template <
class Deleter>
143 inline Ice::Long
getUseCount(
const Ice::Current& = Ice::emptyCurrent)
const override;
148 ClientSideRemoteHandleControlBlockBasePtr
150 inline Ice::ObjectPrx
162 forcedDeletion =
true;
167 Ice::ObjectPrx managedObjectPrx,
168 std::function<
void(
void)> deleter);
175 inline void cleanup();
181 std::function<void(
void)> deleter;
182 Ice::ObjectPrx managedObjectProxy;
186 RemoteHandleControlBlockInterfacePrx selfProxy;
188 mutable std::atomic<uint64_t> useCount{0};
189 mutable std::mutex mtx;
190 mutable clock::time_point lastTimeUseCountReachedZero;
191 mutable std::atomic_bool forcedDeletion{
false};
211 return managedObjectProxy;
215 RemoteHandleControlBlock::cleanup()
222 objectAdapter->remove(selfProxy->ice_getIdentity());
225 template <
class Deleter>
228 Ice::ObjectPrx managedObjectPrx,
232 manager->getAdapter(), std::move(managedObjectPrx), std::move(deleter)};
233 auto clientSideRemoteHandleControlBlock = block->getClientSideRemoteHandleControlBlock();
234 manager->getSharedRemoteHandleState()->add(block);
235 return {block, clientSideRemoteHandleControlBlock};
The periodic task executes one thread method repeatedly using the time period specified in the constr...
IceUtil::Handle< PeriodicTask< SharedRemoteHandleState > > pointer_type
The RemoteHandleControlBlock is the equivalent of the std::shared_ptr's contol_block for a remote han...
void incrementUseCount(const Ice::Current &=Ice::emptyCurrent) override
Increments the usecount.
friend struct SharedRemoteHandleState
std::chrono::steady_clock clock
Ice::Long getUseCount(const Ice::Current &=Ice::emptyCurrent) const override
void decrementUseCount(const Ice::Current &=Ice::emptyCurrent) override
decrements the useCount.
ClientSideRemoteHandleControlBlockBasePtr getClientSideRemoteHandleControlBlock(const Ice::Current &=Ice::emptyCurrent) override
static ManagementData create(ArmarXManagerPtr manager, Ice::ObjectPrx managedObjectPrx, Deleter deleter)
Creates a new RemoteHandleControlBlock.
void forceDeletion()
Call this when you want to force the deletion of the managed object.
Ice::ObjectPrx getManagedObjectProxy(const Ice::Current &=Ice::emptyCurrent) const override
::IceInternal::Handle<::Ice::ObjectAdapter > ObjectAdapterPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< ArmarXManager > ArmarXManagerPtr
IceInternal::Handle< RemoteHandleControlBlock > RemoteHandleControlBlockPtr
Returned by a call to RemoteHandleControlBlock::create.
RemoteHandleControlBlockPtr directHandle
ClientSideRemoteHandleControlBlockBasePtr clientSideRemoteHandleControlBlock
void add(RemoteHandleControlBlockPtr rh)
SharedRemoteHandleState(unsigned int deletionDelayMs)
PeriodicTask< SharedRemoteHandleState > PeriodicTaskType
static const unsigned int DEFAULT_DELETION_DELAY
The amount of time (in ms) required to pass after a RemoteHandleControlBlock's usecount has reacht ze...
~SharedRemoteHandleState()