mirror of
https://github.com/gelldur/EventBus.git
synced 2024-12-27 12:21: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 container;
|
||||||
ContainerType toAdd;
|
ContainerType toAdd;
|
||||||
std::vector<int> toRemove;
|
std::vector<int> toRemove;
|
||||||
bool inTransaction = false;
|
int inTransaction = 0;
|
||||||
|
|
||||||
virtual void remove(const int token) override
|
virtual void remove(const int token) override
|
||||||
{
|
{
|
||||||
if (inTransaction)
|
if (inTransaction > 0)
|
||||||
{
|
{
|
||||||
toRemove.push_back(token);
|
toRemove.push_back(token);
|
||||||
return;
|
return;
|
||||||
@ -163,7 +163,7 @@ private:
|
|||||||
|
|
||||||
void add(const int token, const CallbackType& callback)
|
void add(const int token, const CallbackType& callback)
|
||||||
{
|
{
|
||||||
if (inTransaction)
|
if (inTransaction > 0)
|
||||||
{
|
{
|
||||||
toAdd.emplace_back(token, callback);
|
toAdd.emplace_back(token, callback);
|
||||||
}
|
}
|
||||||
@ -175,12 +175,17 @@ private:
|
|||||||
|
|
||||||
void beginTransaction()
|
void beginTransaction()
|
||||||
{
|
{
|
||||||
inTransaction = true;
|
++inTransaction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void commitTransaction()
|
void commitTransaction()
|
||||||
{
|
{
|
||||||
inTransaction = false;
|
--inTransaction;
|
||||||
|
if (inTransaction > 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inTransaction = 0;
|
||||||
|
|
||||||
if (toAdd.empty() == false)
|
if (toAdd.empty() == false)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user