mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Fix qfvis for android.
pthread_cancel is not (and will not be) implemented, so rework the thread finalization to not need it.
This commit is contained in:
parent
97aa5b8c6d
commit
c0f7b4ba37
1 changed files with 25 additions and 13 deletions
|
@ -80,6 +80,7 @@ int c_portalpass;
|
||||||
int c_portalcheck;
|
int c_portalcheck;
|
||||||
int c_vistest;
|
int c_vistest;
|
||||||
|
|
||||||
|
int portal_count;
|
||||||
int numportals;
|
int numportals;
|
||||||
int portalclusters;
|
int portalclusters;
|
||||||
int numrealleafs;
|
int numrealleafs;
|
||||||
|
@ -271,9 +272,7 @@ GetNextPortal (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p) {
|
if (p) {
|
||||||
static int count;
|
portal_count++;
|
||||||
printf ("%5d / %5d %d\r", count++, numportals * 2, p->nummightsee);
|
|
||||||
fflush (stdout);
|
|
||||||
p->status = stat_selected;
|
p->status = stat_selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,6 +303,9 @@ LeafThread (void *_thread)
|
||||||
portal->numcansee);
|
portal->numcansee);
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
|
printf ("thread %d done\n", thread);
|
||||||
|
if (working)
|
||||||
|
working[thread] = -1;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -314,18 +316,30 @@ WatchThread (void *_thread)
|
||||||
int *local_work = malloc (thread * sizeof (int));
|
int *local_work = malloc (thread * sizeof (int));
|
||||||
int i;
|
int i;
|
||||||
const char *spinner = "|/-\\";
|
const char *spinner = "|/-\\";
|
||||||
int ind = 0;
|
int spinner_ind = 0;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
usleep (1000000);
|
usleep (1000);
|
||||||
|
|
||||||
for (i = 0; i < thread; i ++)
|
for (i = 0; i < thread; i ++)
|
||||||
local_work[i] = working[i];
|
if (working[i] >= 0)
|
||||||
for (i = 0; i < thread; i++)
|
break;
|
||||||
printf ("%6d", local_work[i]);
|
if (i == thread)
|
||||||
printf (" %c\r", spinner[(ind++) % 4]);
|
break;
|
||||||
fflush (stdout);
|
if (count++ == 1000) {
|
||||||
|
count = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < thread; i ++)
|
||||||
|
local_work[i] = working[i];
|
||||||
|
for (i = 0; i < thread; i++)
|
||||||
|
printf ("%6d", local_work[i]);
|
||||||
|
printf (" %5d / %5d", portal_count, numportals * 2);
|
||||||
|
fflush (stdout);
|
||||||
|
printf (" %c\r", spinner[(spinner_ind++) % 4]);
|
||||||
|
fflush (stdout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
printf ("watch thread done\n");
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -466,8 +480,6 @@ CalcPortalVis (void)
|
||||||
if (pthread_join (work_threads[i], &status) == -1)
|
if (pthread_join (work_threads[i], &status) == -1)
|
||||||
Sys_Error ("pthread_join failed");
|
Sys_Error ("pthread_join failed");
|
||||||
}
|
}
|
||||||
if (pthread_cancel (work_threads[i]) != 0)
|
|
||||||
Sys_Error ("pthread_cancel failed");
|
|
||||||
if (pthread_join (work_threads[i], &status) == -1)
|
if (pthread_join (work_threads[i], &status) == -1)
|
||||||
Sys_Error ("pthread_join failed");
|
Sys_Error ("pthread_join failed");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue