Add checks to sample task systems to ensure that TasksInit has been

called; if not, print an informative error message.
This commit is contained in:
Matt Pharr
2011-07-01 14:11:16 +01:00
parent d2d5858be1
commit 6ed6961958
3 changed files with 36 additions and 0 deletions

View File

@@ -135,6 +135,11 @@ TasksInit() {
void
ISPCLaunch(void *f, void *d) {
if (threads == NULL) {
fprintf(stderr, "You must call TasksInit() before launching tasks.\n");
exit(1);
}
//
// Acquire mutex, add task
//
@@ -256,6 +261,11 @@ lTaskEntry(void *arg) {
void ISPCSync() {
if (threads == NULL) {
fprintf(stderr, "You must call TasksInit() before launching tasks.\n");
exit(1);
}
int err;
if ((err = pthread_mutex_lock(&tasksRunningConditionMutex)) != 0) {
fprintf(stderr, "Error from pthread_mutex_lock: %s\n", strerror(err));