Home » Community » Coffee corner » What is the best way to create a Semaphore with timeout?  
	
		
		
			| What is the best way to create a Semaphore with timeout? [message #52857] | 
			Tue, 17 December 2019 09:49   | 
		 
		
			
				
				
				
					
						
						Tom1
						 Messages: 1305 Registered: March 2007 
						
					 | 
					Ultimate Contributor  | 
					 | 
		 
		 
	 | 
 
	
		Hi, 
 
I need a Semaphore with Wait(int timeout_ms); What is the best way (in terms of efficiency) to implement this timeout functionality? 
 
Using SetTimeCallback() to Release() the Semaphore is not an option in non-GUI environment. Another thread Sleeping for the specified amount of time and then calling Release feels a bit inefficient. 
 
(For the background: I'm building a FIFO using BiVector and wish to get minimal latency and overhead for the operation.) 
 
Best regards, 
 
Tom
		
		
		
 |  
	| 
		
	 | 
 
 
 |  
  
 
	
	  | 
	 | 
	
		What is the best way to create a Semaphore with timeout?
		By:  Tom1 on Tue, 17 December 2019 09:49  
	 | 
 
	  | 
	 | 
	
		Re: What is the best way to create a Semaphore with timeout?
		By:  Tom1 on Tue, 17 December 2019 10:49  
	 | 
 
	  | 
	 | 
	
		Re: What is the best way to create a Semaphore with timeout?
		By:  Tom1 on Tue, 17 December 2019 11:53  
	 | 
 
	  | 
	 | 
	
		Re: What is the best way to create a Semaphore with timeout?
		By:  mirek on Thu, 19 December 2019 11:38  
	 | 
 
	  | 
	 | 
	
		Re: What is the best way to create a Semaphore with timeout?
		By:  Tom1 on Thu, 19 December 2019 12:59  
	 | 
 
	  | 
	 | 
	
		Re: What is the best way to create a Semaphore with timeout?
		By:  mirek on Thu, 19 December 2019 13:40  
	 | 
 
	  | 
	 | 
	
		Re: What is the best way to create a Semaphore with timeout?
		By:  Tom1 on Thu, 19 December 2019 14:38  
	 | 
 
	  | 
	 | 
	
		Re: What is the best way to create a Semaphore with timeout?
		By:  mirek on Thu, 19 December 2019 17:05  
	 | 
 
	  | 
	 | 
	
		Re: What is the best way to create a Semaphore with timeout?
		By:  Tom1 on Thu, 19 December 2019 21:44  
	 | 
 
	  | 
	 | 
	
		Re: What is the best way to create a Semaphore with timeout?
		By:  mirek on Wed, 22 January 2020 14:44  
	 | 
 
	  | 
	 | 
	
		Re: What is the best way to create a Semaphore with timeout?
		By:  Tom1 on Wed, 22 January 2020 14:48  
	 | 
  
Goto Forum:
 
 Current Time: Tue Nov 04 03:15:37 CET 2025 
 Total time taken to generate the page: 0.04257 seconds 
 |