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; volatile bool BConnLocked = false;
void BConInc() void BConInc()
{ {
while(BConnLocked == true) Sleep(6); __asm
{
BConnLocked = true; lock inc BrutingThrds;
++BrutingThrds; };
BConnLocked = false;
#pragma region QTGUI_Area #pragma region QTGUI_Area
stt->doEmitionChangeBA(QString::number(BrutingThrds)); stt->doEmitionChangeBA(QString::number(BrutingThrds));
#pragma endregion #pragma endregion
@ -27,11 +26,10 @@ void BConInc()
}; };
void BConDec() void BConDec()
{ {
while(BConnLocked == true) Sleep(8); __asm
{
BConnLocked = true; lock dec BrutingThrds;
if(BrutingThrds > 0) --BrutingThrds; };
BConnLocked = false;
#pragma region QTGUI_Area #pragma region QTGUI_Area
stt->doEmitionChangeBA(QString::number(BrutingThrds)); stt->doEmitionChangeBA(QString::number(BrutingThrds));
#pragma endregion #pragma endregion
@ -39,22 +37,20 @@ void BConDec()
bool SSHConnLocked = false; bool SSHConnLocked = false;
void SSHConInc() void SSHConInc()
{ {
while(SSHConnLocked == true) Sleep(6); __asm
{
SSHConnLocked = true; lock inc BrutingThrds;
++BrutingThrds; };
SSHConnLocked = false;
#pragma region QTGUI_Area #pragma region QTGUI_Area
stt->doEmitionChangeBA(QString::number(BrutingThrds)); stt->doEmitionChangeBA(QString::number(BrutingThrds));
#pragma endregion #pragma endregion
}; };
void SSHConDec() void SSHConDec()
{ {
while(SSHConnLocked == true) Sleep(6); __asm
{
SSHConnLocked = true; lock dec BrutingThrds;
if(BrutingThrds > 0) --BrutingThrds; };
SSHConnLocked = false;
#pragma region QTGUI_Area #pragma region QTGUI_Area
stt->doEmitionChangeBA(QString::number(BrutingThrds)); stt->doEmitionChangeBA(QString::number(BrutingThrds));
#pragma endregion #pragma endregion

View File

@ -134,35 +134,20 @@ QString GetNSErrorDefinition(char *str, char *elem)
}; };
void ConInc() void ConInc()
{ {
while(ConnLocked) Sleep(20);
ConnLocked = true;
__asm __asm
{ {
add cons, 1; lock inc cons;
}; };
ConnLocked = false;
#pragma region QTGUI_Area #pragma region QTGUI_Area
stt->doEmitionThreads(QString::number(cons) + "/" + QString::number(gThreads)); stt->doEmitionThreads(QString::number(cons) + "/" + QString::number(gThreads));
#pragma endregion #pragma endregion
}; };
volatile bool ConnLocked2 = false;
void ConDec() 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 #pragma region QTGUI_Area
stt->doEmitionThreads(QString::number(cons) + "/" + QString::number(gThreads)); stt->doEmitionThreads(QString::number(cons) + "/" + QString::number(gThreads));
#pragma endregion #pragma endregion