Skip to content

Commit 68a5638

Browse files
Performance enhancement in Token
1 parent 30273f5 commit 68a5638

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

fUML-CPP/fuml/src/fuml/semantics/activities/Token.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ TokenPtr Token::transfer(const ActivityNodeActivationPtr& holder)
3333
}
3434

3535
token->holder = holder;
36+
this->_isWithdrawn = false;
3637
return token;
3738
} // transfer
3839

@@ -45,12 +46,13 @@ void Token::withdraw()
4546
TokenPtr thisTokenPtrLocked = this->thisTokenPtr.lock(); // This is done so this token won't be deleted (i.e. it's memory is freed) by the next line in case it is only referenced by it's holder
4647
this->holder.lock()->removeToken(this->thisTokenPtr.lock());
4748
this->holder.reset();
49+
this->_isWithdrawn = true;
4850
}
4951
} // withdraw
5052

5153
bool Token::isWithdrawn()
5254
{
5355
// Test if this token has been withdrawn.
5456

55-
return this->holder.lock() == nullptr;
57+
return this->_isWithdrawn;
5658
} // isWithdrawn

fUML-CPP/fuml/src/fuml/semantics/activities/Token.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ namespace fuml::semantics::activities
2020

2121
private:
2222
TokenPtr_w thisTokenPtr;
23+
bool _isWithdrawn = false;
2324

2425
public:
2526
virtual ~Token() = 0;

0 commit comments

Comments
 (0)