Reorder nthread.h

This commit is contained in:
Anders Jenbo 2020-11-04 18:32:24 +01:00
commit b31da5aec3
2 changed files with 26 additions and 33 deletions

View file

@ -107,6 +107,32 @@ BOOL nthread_recv_turns(BOOL *pfSendAsync)
}
}
static unsigned int __stdcall nthread_handler(void *data)
{
int delta;
BOOL received;
if (nthread_should_run) {
while (1) {
sgMemCrit.Enter();
if (!nthread_should_run)
break;
nthread_send_and_recv_turn(0, 0);
if (nthread_recv_turns(&received))
delta = last_tick - GetTickCount();
else
delta = 50;
sgMemCrit.Leave();
if (delta > 0)
Sleep(delta);
if (!nthread_should_run)
return 0;
}
sgMemCrit.Leave();
}
return 0;
}
void nthread_set_turn_upper_bit()
{
turn_upper_bit = 0x80000000;
@ -168,32 +194,6 @@ void nthread_start(BOOL set_turn_upper_bit)
}
}
unsigned int __stdcall nthread_handler(void *data)
{
int delta;
BOOL received;
if (nthread_should_run) {
while (1) {
sgMemCrit.Enter();
if (!nthread_should_run)
break;
nthread_send_and_recv_turn(0, 0);
if (nthread_recv_turns(&received))
delta = last_tick - GetTickCount();
else
delta = 50;
sgMemCrit.Leave();
if (delta > 0)
Sleep(delta);
if (!nthread_should_run)
return 0;
}
sgMemCrit.Leave();
}
return 0;
}
void nthread_cleanup()
{
nthread_should_run = FALSE;