comparison mac/dw.m @ 695:3b17111499bf

Minor updates to the last commit.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 10 Mar 2011 19:36:47 +0000
parents 130ca42c4ae3
children 516e0c09d4b9
comparison
equal deleted inserted replaced
694:130ca42c4ae3 695:3b17111499bf
1716 DWTID orig = DWThread; 1716 DWTID orig = DWThread;
1717 1717
1718 gettimeofday(&tv, NULL); 1718 gettimeofday(&tv, NULL);
1719 1719
1720 dw_mutex_lock(DWRunMutex); 1720 dw_mutex_lock(DWRunMutex);
1721 if(orig == (DWTID)-1)
1722 {
1723 DWThread = curr;
1724 }
1721 while(((tv.tv_sec - start.tv_sec)*1000) + ((tv.tv_usec - start.tv_usec)/1000) <= milliseconds) 1725 while(((tv.tv_sec - start.tv_sec)*1000) + ((tv.tv_usec - start.tv_usec)/1000) <= milliseconds)
1722 { 1726 {
1723 if(orig == (DWTID)-1) 1727 dw_main_iteration();
1724 { 1728 gettimeofday(&tv, NULL);
1725 DWThread = curr; 1729 }
1726 } 1730 if(orig == (DWTID)-1)
1727 dw_main_iteration(); 1731 {
1728 if(orig == (DWTID)-1) 1732 DWThread = orig;
1729 {
1730 DWThread = orig;
1731 }
1732 gettimeofday(&tv, NULL);
1733 } 1733 }
1734 dw_mutex_unlock(DWRunMutex); 1734 dw_mutex_unlock(DWRunMutex);
1735 } 1735 }
1736 else 1736 else
1737 usleep(milliseconds * 1000); 1737 usleep(milliseconds * 1000);
6501 * will deadlock... so try to acquire the lock and continue 6501 * will deadlock... so try to acquire the lock and continue
6502 * processing messages in between tries. 6502 * processing messages in between tries.
6503 */ 6503 */
6504 if(DWThread == pthread_self()) 6504 if(DWThread == pthread_self())
6505 { 6505 {
6506 pthread_mutex_unlock(DWRunMutex);
6507 while(pthread_mutex_trylock(mutex) != 0) 6506 while(pthread_mutex_trylock(mutex) != 0)
6508 { 6507 {
6509 dw_main_iteration(); 6508 dw_main_iteration();
6510 } 6509 }
6511 pthread_mutex_lock(DWRunMutex);
6512 } 6510 }
6513 else 6511 else
6514 { 6512 {
6515 pthread_mutex_lock(mutex); 6513 pthread_mutex_lock(mutex);
6516 } 6514 }