lock inc/lock dec

This commit is contained in:
cora32 2014-10-24 19:28:37 +03:00
parent e784b1d566
commit e12f25da06
2 changed files with 19 additions and 38 deletions

View File

@ -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

View File

@ -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
{
sub cons, 1;
lock dec cons;
};
};
ConnLocked2 = false;
ConnLocked = false;
#pragma region QTGUI_Area
stt->doEmitionThreads(QString::number(cons) + "/" + QString::number(gThreads));
#pragma endregion