00001 /****************************************************************** 00002 * CAVERNsoft 00003 * Copyright (C) 1994-2000 Electronic Visualization Laboratory, 00004 * all rights reserved 00005 * By Jason Leigh, Yong-joo Cho, Naveen Krishnaprasad, Chris Scharver, 00006 * Stuart Bailey, Atul Nayak, Shalini Venkataraman 00007 * University of Illinois at Chicago 00008 * 00009 * This publication and its text and code may not be copied for commercial 00010 * use without the express written permission of the University of Illinois 00011 * at Chicago. 00012 * The contributors disclaim any representation of warranty: use this 00013 * code at your own risk. 00014 * Direct questions, comments etc to cavern@evl.uic.edu 00015 ******************************************************************/ 00016 00017 #if defined(WIN32) && defined(CAVERN_USE_WINDOWSTHREADS) 00018 00019 #ifndef __PTHREAD_WIN_H_ 00020 #define __PTHREAD_WIN_H_ 00021 00022 /* This program is largely based on "Strategies for Implementing POSIX Condition 00023 Variables on Win32" written by Douglas C. Schmidt and Irfan Pyarali and published 00024 in C++ Report, Vol. 10, No. 5, June, 1998 issue. You can get the full article from 00025 "http://www.cs.wustl.edu/~schmidt/win32-cv-1.html". I fixed a few things from the 00026 code and added pthread_win_cond_destroy function. 00027 */ 00028 00029 #include <windows.h> 00030 #include "CAVERNts_mutex_c.hxx" 00031 00032 struct pthread_win_cond_t 00033 { 00034 int waiters_count_; 00035 // Count of the number of waiters. 00036 00037 CRITICAL_SECTION waiters_count_lock_; 00038 // Serialize access to <waiters_count_>. 00039 00040 int release_count_; 00041 // Number of threads to release via a <pthread_cond_broadcast> or a 00042 // <pthread_cond_signal>. 00043 00044 int wait_generation_count_; 00045 // Keeps track of the current "generation" so that we don't allow 00046 // one thread to steal all the "releases" from the broadcast. 00047 00048 HANDLE event_; 00049 // A manual-reset event that's used to block and release waiting 00050 // threads. 00051 }; 00052 00053 int pthread_win_cond_init(struct pthread_win_cond_t *cv); 00054 int pthread_win_cond_wait(struct pthread_win_cond_t *cv, 00055 CAVERNts_mutex_c *external_mutex); 00056 int pthread_win_cond_signal(struct pthread_win_cond_t *cv); 00057 int pthread_win_cond_broadcast(struct pthread_win_cond_t *cv); 00058 int pthread_win_cond_destroy(struct pthread_win_cond_t *cv); 00059 00060 #endif 00061 00062 #endif