| Author | 
		  Message
		 | 
		
		  | veeru_hyd | 
		  
		    
			  
				 Posted: Fri Oct 29, 2010 9:10 am    Post subject: Delay 20 Milliseconds | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 28 Oct 2010 Posts: 23
  
  | 
		  
		    
			  
				Hi,
 
 
     I am working on esql coding to write the code for delaying for 20milliseconds to repost the message in retry mechanism without using timer nodes.
 
 
 I have written the piece of code below in esql to hold the control in a loop for 20 milli secods, but i am getting a problem. I am providing comment to the result of each statement, what i am getting. Could any one let me know, where or what is the problem?. 
 
 
DECLARE startTimeStamp TIME;
 
DECLARE curTimeStamp TIME;
 
DECLARE outTime TIME;
 
 
SET startTimeStamp = CURRENT_TIME;  -- Result of this statement: 10:34:22:124
 
SET outTime = EVAL('startTimeStamp + INTERVAL ''0.02'' SECOND');-- Result of this statement: 10:34:22:144(Incremented with 20 Milli seconds)
 
 
SET curTimeStamp = CURRENT_TIME;-- Result of this statement: 10:34:22:124(Getting the same result 'startTimeStamp')
 
WHILE outTime >= curTimeStamp DO
 
     SET curTimeStamp = CURRENT_TIME;-- Result of this statement: 10:34:22:124(Getting the same result 'startTimeStamp', Its going to infinite loop. Because CURRENT_TIME is not returning the correct value from second time onwards.)
 
END WHILE;
 
 
 
Thanks,
 
Veera Kumar | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Fri Oct 29, 2010 9:22 am    Post subject: Re: Delay 20 Milliseconds | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| veeru_hyd wrote: | 
   
  
	| Could any one let me know, where or what is the problem?.  | 
   
 
 
 
The problem is you're not reading this, which clearly says:
 
 
   
	| Quote: | 
   
  
	| All calls to CURRENT_TIME within the processing of one node are guaranteed to return the same value | 
   
 
 
 
  _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mgk | 
		  
		    
			  
				 Posted: Fri Oct 29, 2010 9:23 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Padawan
 
 Joined: 31 Jul 2003 Posts: 1647
  
  | 
		  
		    
			  
				CURRENT_TIME (and friends) always return the same value through the entire node. This is documented behaviour... _________________ MGK
 
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | veeru_hyd | 
		  
		    
			  
				 Posted: Fri Oct 29, 2010 9:36 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		   Novice
 
 Joined: 28 Oct 2010 Posts: 23
  
  | 
		  
		    
			  
				Oh!!   
 
 
Thank you very much for your valuable reply.
 
 
Regards,
 
Veera | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | rekarm01 | 
		  
		    
			  
				 Posted: Fri Oct 29, 2010 9:54 am    Post subject: Re: Delay 20 Milliseconds | 
				     | 
			   
			 
		   | 
		
		
		   Grand Master
 
 Joined: 25 Jun 2008 Posts: 1415
  
  | 
		  
		    
			  
				
   
	| veeru_hyd wrote: | 
   
  
	
   
	| Code: | 
   
  
	WHILE outTime >= curTimeStamp DO
 
     SET curTimeStamp = CURRENT_TIME;
 
END WHILE; | 
   
 
 | 
   
 
 
One other point: a busy-wait loop is probably the worst way to delay processing within a thread.  Other threads might want some CPU time too.
 
 
Use the Timer nodes, or perhaps write a wrapper function to call Java's Thread.sleep(). | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | zpat | 
		  
		    
			  
				 Posted: Fri Oct 29, 2010 9:56 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Jedi Council
 
 Joined: 19 May 2001 Posts: 5867 Location: UK 
  | 
		  
		    
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | Vitor | 
		  
		    
			  
				 Posted: Fri Oct 29, 2010 10:46 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Grand High Poobah
 
 Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA 
  | 
		  
		    
			  
				
   
	| zpat wrote: | 
   
  
	| Do NOT loop like this, you will cause the CPU % to hit 100% and turn a multitasking system into a looping single tasking system. | 
   
 
 
 
 
 
 
 
 
Does it have this below v7? _________________ Honesty is the best policy.
 
Insanity is the best defence. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | mgk | 
		  
		    
			  
				 Posted: Fri Oct 29, 2010 10:48 am    Post subject:  | 
				     | 
			   
			 
		   | 
		
		
		    Padawan
 
 Joined: 31 Jul 2003 Posts: 1647
  
  | 
		  
		    
			  
				
   
	| Quote: | 
   
  
	| Does it have this below v7? | 
   
 
 
 
No, SLEEP is new in 7.0.0.1 _________________ MGK
 
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. | 
			   
			 
		   | 
		
		
		  | Back to top | 
		  
		  	
		   | 
		
		
		    | 
		
		
		  | 
		    
		   |