diff --git a/connector.cpp b/connector.cpp index b76bcf0..2509544 100644 --- a/connector.cpp +++ b/connector.cpp @@ -15,11 +15,10 @@ int gMaxBrutingThreads = 200; volatile bool BConnLocked = false; void BConInc() { - while(BConnLocked == true) Sleep(6); - - BConnLocked = true; - ++BrutingThrds; - BConnLocked = false; + __asm + { + lock inc BrutingThrds; + }; #pragma region QTGUI_Area stt->doEmitionChangeBA(QString::number(BrutingThrds)); #pragma endregion @@ -27,11 +26,10 @@ void BConInc() }; void BConDec() { - while(BConnLocked == true) Sleep(8); - - BConnLocked = true; - if(BrutingThrds > 0) --BrutingThrds; - BConnLocked = false; + __asm + { + lock dec BrutingThrds; + }; #pragma region QTGUI_Area stt->doEmitionChangeBA(QString::number(BrutingThrds)); #pragma endregion @@ -39,22 +37,20 @@ void BConDec() bool SSHConnLocked = false; void SSHConInc() { - while(SSHConnLocked == true) Sleep(6); - - SSHConnLocked = true; - ++BrutingThrds; - SSHConnLocked = false; + __asm + { + lock inc BrutingThrds; + }; #pragma region QTGUI_Area stt->doEmitionChangeBA(QString::number(BrutingThrds)); #pragma endregion }; void SSHConDec() { - while(SSHConnLocked == true) Sleep(6); - - SSHConnLocked = true; - if(BrutingThrds > 0) --BrutingThrds; - SSHConnLocked = false; + __asm + { + lock dec BrutingThrds; + }; #pragma region QTGUI_Area stt->doEmitionChangeBA(QString::number(BrutingThrds)); #pragma endregion diff --git a/nesca_startModule.cpp b/nesca_startModule.cpp index 220982b..4c593be 100644 --- a/nesca_startModule.cpp +++ b/nesca_startModule.cpp @@ -134,35 +134,20 @@ QString GetNSErrorDefinition(char *str, char *elem) }; void ConInc() { - while(ConnLocked) Sleep(20); - - ConnLocked = true; __asm { - add cons, 1; + lock inc cons; }; - ConnLocked = false; #pragma region QTGUI_Area stt->doEmitionThreads(QString::number(cons) + "/" + QString::number(gThreads)); #pragma endregion }; -volatile bool ConnLocked2 = false; void ConDec() { - while(ConnLocked) Sleep(10 + (rand() % 5 + 1)); - - ConnLocked = true; - while(ConnLocked2) Sleep(18); - ConnLocked2 = true; - if(cons > 0) + __asm { - __asm - { - sub cons, 1; - }; + lock dec cons; }; - ConnLocked2 = false; - ConnLocked = false; #pragma region QTGUI_Area stt->doEmitionThreads(QString::number(cons) + "/" + QString::number(gThreads)); #pragma endregion