site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On 24 Nov 2008, at 04:28, Rakesh Singhal wrote: pthread_cond_signal() leaves the object nonsignaled like PulseEvent() in Win32. Is there any POSIX or Mac function which leaves the object signaled like SetEvent() in Win32? Counting semaphore will not fit in my case. typedef struct _persistent_event { pthread_cond_t cond; pthread_mutex_t mutex; int isset; } t_persistent_event; t_persistent_event *NewEvent(void) { t_persistent_event *event = malloc(sizeof(*event)); pthread_cond_init(&event->condvar, NULL); pthread_mutex_init(&event->mutex, NULL); event->isset=0; return event; } void SetEvent(t_persistent_event *event) { pthread_mutex_lock(&event->mutex); event->isset=1; pthread_cond_signal(&event->cond); pthread_mutex_unlock(&event->mutex); } void WaitEvent(t_persistent_event *event) { pthread_mutex_lock(&event->mutex); while (!event->isset) pthread_cond_wait(&event->condvar,&event->mutex); event->isset=0; pthread_mutex_unlock(&event->mutex); } ResetEvent() and DestroyEvent() left as an exercise to the reader. Jonas _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... There is none in the pthread_* family at least. But you can implement one on top of them using something like this (typed in Mail): This email sent to site_archiver@lists.apple.com
participants (1)
-
Jonas Maebe