l->first=NULL;
l->last=NULL;
l->count=0;
+
+ #ifdef MT_SAFE_LIST
pthread_cond_init(&l->cond, NULL);
pthread_mutex_init(&l->mutex, NULL);
+ #endif
return l;
}
+ #ifdef MT_SAFE_LIST
pthread_mutex_destroy(&l->mutex);
pthread_cond_destroy(&l->cond);
+ #endif
for (ln=l->first; ln!=NULL; ) {
}
+ #ifdef MT_SAFE_LIST
pthread_mutex_lock(&l->mutex);
+ #endif
ln=malloc(sizeof(ListNode));
ln->data=data;
l->first=ln;
l->count++;
+ #ifdef MT_SAFE_LIST
pthread_mutex_unlock(&l->mutex);
pthread_cond_broadcast(&l->cond);
+ #endif
}
}
+ #ifdef MT_SAFE_LIST
pthread_mutex_lock(&l->mutex);
+ #endif
ln=malloc(sizeof(ListNode));
ln->data=data;
l->last=ln;
l->count++;
+ #ifdef MT_SAFE_LIST
pthread_mutex_unlock(&l->mutex);
pthread_cond_broadcast(&l->cond);
+ #endif
}
}
+ #ifdef MT_SAFE_LIST
pthread_mutex_lock(&l->mutex);
+ #endif
if ( (ln=l->first)==NULL ) {
+ #ifdef MT_SAFE_LIST
pthread_mutex_unlock(&l->mutex);
+ #endif
return NULL;
}
l->count--;
free(ln);
+ #ifdef MT_SAFE_LIST
pthread_mutex_unlock(&l->mutex);
pthread_cond_broadcast(&l->cond);
+ #endif
return data;
}
+ #ifdef MT_SAFE_LIST
pthread_mutex_lock(&l->mutex);
+ #endif
if ( (ln=l->last)==NULL ) {
+ #ifdef MT_SAFE_LIST
pthread_mutex_unlock(&l->mutex);
+ #endif
return NULL;
}
l->count--;
free(ln);
+ #ifdef MT_SAFE_LIST
pthread_mutex_unlock(&l->mutex);
pthread_cond_broadcast(&l->cond);
-
+ #endif
return data;
}
+ #ifdef MT_SAFE_LIST
pthread_mutex_lock(&l->mutex);
+ #endif
for (ln=l->first; ln!=NULL; ) {
l->last=NULL;
l->count=0;
+ #ifdef MT_SAFE_LIST
pthread_mutex_unlock(&l->mutex);
pthread_cond_broadcast(&l->cond);
-
+ #endif
}
}
+ #ifdef MT_SAFE_LIST
pthread_mutex_lock(&l->mutex);
+ #endif
for (ln=l->first; ln!=NULL && ln->data!=data; ln=ln->next);
if ( ln==NULL ) {
+ #ifdef MT_SAFE_LIST
pthread_mutex_unlock(&l->mutex);
+ #endif
} else {
l->count--;
+ #ifdef MT_SAFE_LIST
pthread_mutex_unlock(&l->mutex);
pthread_cond_broadcast(&l->cond);
+ #endif
}
}
+ #ifdef MT_SAFE_LIST
pthread_mutex_lock(&l->mutex);
+ #endif
for (ln=l->first; ln!=NULL; ln=ln->next) {
browsefunc(ln->data);
}
+ #ifdef MT_SAFE_LIST
pthread_mutex_unlock(&l->mutex);
-
+ #endif
}
}
+ #ifdef MT_SAFE_LIST
pthread_mutex_lock(&l->mutex);
+ #endif
if ( l->count>0 ) {
}
+ #ifdef MT_SAFE_LIST
pthread_mutex_unlock(&l->mutex);
+ #endif
return tab;