mirror of
				https://github.com/zeromq/libzmq.git
				synced 2025-10-28 11:31:56 +01:00 
			
		
		
		
	Pull request to merge porting to WindRiver VxWorks 6.x (#2966)
* Problem: Still need to port over more files to VxWorks 6.x Solution: Port more files to VxWorks 6.x * Problem: Need to port over remaining files to VxWorks 6.x. Also remove POSIX thread dependency for VxWorks (because of priority inversion problem in POSIX mutexes with VxWorks 6.x processes) Solution: Port over remaining files to VxWorks 6.x. Also removed POSIX thread dependency for VxWorks * Problem: Needed to modify TCP, UDP, TIPC classes with #ifdefs to be compatible with VxWorks 6.x. Solution: Modify TCP, UDP, TIPC classes with #ifdefs to be compatible with VxWorks 6.x
This commit is contained in:
		 Manuel Segura
					Manuel Segura
				
			
				
					committed by
					
						 Luca Boccassi
						Luca Boccassi
					
				
			
			
				
	
			
			
			 Luca Boccassi
						Luca Boccassi
					
				
			
						parent
						
							0d23b5ca69
						
					
				
				
					commit
					4726f7262d
				
			| @@ -170,6 +170,90 @@ class condition_variable_t | ||||
|  | ||||
| #endif | ||||
|  | ||||
| #elif defined ZMQ_HAVE_VXWORKS | ||||
|  | ||||
| #include <sysLib.h> | ||||
|  | ||||
| namespace zmq | ||||
| { | ||||
| class condition_variable_t | ||||
| { | ||||
|   public: | ||||
|     inline condition_variable_t () {} | ||||
|  | ||||
|     inline ~condition_variable_t () | ||||
|     { | ||||
|         scoped_lock_t l (m_listenersMutex); | ||||
|         for (size_t i = 0; i < m_listeners.size (); i++) { | ||||
|             semDelete (m_listeners[i]); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     inline int wait (mutex_t *mutex_, int timeout_) | ||||
|     { | ||||
|         //Atomically releases lock, blocks the current executing thread, | ||||
|         //and adds it to the list of threads waiting on *this. The thread | ||||
|         //will be unblocked when broadcast() is executed. | ||||
|         //It may also be unblocked spuriously. When unblocked, regardless | ||||
|         //of the reason, lock is reacquired and wait exits. | ||||
|  | ||||
|         SEM_ID sem = semBCreate (SEM_Q_PRIORITY, SEM_EMPTY); | ||||
|         { | ||||
|             scoped_lock_t l (m_listenersMutex); | ||||
|             m_listeners.push_back (sem); | ||||
|         } | ||||
|         mutex_->unlock (); | ||||
|  | ||||
|         int rc; | ||||
|         if (timeout_ < 0) | ||||
|             rc = semTake (sem, WAIT_FOREVER); | ||||
|         else { | ||||
|             int ticksPerSec = sysClkRateGet (); | ||||
|             int timeoutTicks = (timeout_ * ticksPerSec) / 1000 + 1; | ||||
|             rc = semTake (sem, timeoutTicks); | ||||
|         } | ||||
|  | ||||
|         { | ||||
|             scoped_lock_t l (m_listenersMutex); | ||||
|             // remove sem from listeners | ||||
|             for (size_t i = 0; i < m_listeners.size (); i++) { | ||||
|                 if (m_listeners[i] == sem) { | ||||
|                     m_listeners.erase (m_listeners.begin () + i); | ||||
|                     break; | ||||
|                 } | ||||
|             } | ||||
|             semDelete (sem); | ||||
|         } | ||||
|         mutex_->lock (); | ||||
|  | ||||
|         if (rc == 0) | ||||
|             return 0; | ||||
|  | ||||
|         if (rc == S_objLib_OBJ_TIMEOUT) { | ||||
|             errno = EAGAIN; | ||||
|             return -1; | ||||
|         } | ||||
|  | ||||
|         return -1; | ||||
|     } | ||||
|  | ||||
|     inline void broadcast () | ||||
|     { | ||||
|         scoped_lock_t l (m_listenersMutex); | ||||
|         for (size_t i = 0; i < m_listeners.size (); i++) { | ||||
|             semGive (m_listeners[i]); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   private: | ||||
|     mutex_t m_listenersMutex; | ||||
|     std::vector<SEM_ID> m_listeners; | ||||
|  | ||||
|     // Disable copy construction and assignment. | ||||
|     condition_variable_t (const condition_variable_t &); | ||||
|     const condition_variable_t &operator= (const condition_variable_t &); | ||||
| }; | ||||
| } | ||||
| #else | ||||
|  | ||||
| #include <pthread.h> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user