mirror of
https://github.com/gelldur/EventBus.git
synced 2024-12-26 18:51:02 +08:00
Fix nested transaction
Quick fix for now. Probably we need better solution.
This commit is contained in:
parent
9126286acc
commit
0d34eb9041
@ -139,11 +139,11 @@ private:
|
||||
ContainerType container;
|
||||
ContainerType toAdd;
|
||||
std::vector<int> toRemove;
|
||||
bool inTransaction = false;
|
||||
int inTransaction = 0;
|
||||
|
||||
virtual void remove(const int token) override
|
||||
{
|
||||
if (inTransaction)
|
||||
if (inTransaction > 0)
|
||||
{
|
||||
toRemove.push_back(token);
|
||||
return;
|
||||
@ -163,7 +163,7 @@ private:
|
||||
|
||||
void add(const int token, const CallbackType& callback)
|
||||
{
|
||||
if (inTransaction)
|
||||
if (inTransaction > 0)
|
||||
{
|
||||
toAdd.emplace_back(token, callback);
|
||||
}
|
||||
@ -175,12 +175,17 @@ private:
|
||||
|
||||
void beginTransaction()
|
||||
{
|
||||
inTransaction = true;
|
||||
++inTransaction;
|
||||
}
|
||||
|
||||
void commitTransaction()
|
||||
{
|
||||
inTransaction = false;
|
||||
--inTransaction;
|
||||
if (inTransaction > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
inTransaction = 0;
|
||||
|
||||
if (toAdd.empty() == false)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user