33 std::lock_guard<std::mutex> guard{mtx};
37 lastTimeUseCountReachedZero = clock::now();
41 ClientSideRemoteHandleControlBlockBasePtr
44 assert(managedObjectProxy);
50 Ice::ObjectPrx managedObjectPrx,
51 std::function<
void()> deleter) :
52 objectAdapter{std::move(objectAdapter)},
53 deleter{std::move(deleter)},
54 managedObjectProxy{std::move(managedObjectPrx)}
58 throw std::invalid_argument{
59 "RemoteHandleControlBlock() called with a null object adapter."};
61 if (!managedObjectPrx)
63 throw std::invalid_argument{
"RemoteHandleControlBlock() called with a null proxy."};
67 ident.name =
"RemoteHandleControlBlock::" + managedObjectProxy->ice_getIdentity().name +
68 "::" + IceUtil::generateUUID();
69 selfProxy = RemoteHandleControlBlockInterfacePrx::uncheckedCast(
70 objectAdapter->add(
this, std::move(ident)));
74 deletionDelay{deletionDelayMs},
75 sweeper{
new PeriodicTaskType{
this,
76 &armarx::SharedRemoteHandleState::sweep,
77 static_cast<int>(deletionDelayMs)}}
84 std::lock_guard<std::mutex> stateGuard{stateMutex};
98 std::lock_guard<std::mutex> stateGuard{stateMutex};
99 rhs.emplace(std::move(rh));
103 SharedRemoteHandleState::sweep()
105 auto deletionTime = RemoteHandleControlBlock::clock::now() - deletionDelay;
106 std::lock_guard<std::mutex> stateGuard{stateMutex};
107 auto blockIt = rhs.begin();
108 while (blockIt != rhs.end())
110 auto curBlockIt = blockIt++;
111 auto& block = *curBlockIt;
113 std::unique_lock<std::mutex> blockGuard{block->mtx};
116 (!block->useCount && deletionTime > block->lastTimeUseCountReachedZero) ||
117 block->forcedDeletion)
122 rhs.erase(std::move(curBlockIt));