Advertisement
Guest User

RecycleTimers

a guest
Jun 5th, 2012
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1.  
  2. library RecycleTimers
  3.     struct SimpleTimers extends array
  4.         private static timer array availableTimers
  5.         private static integer maxAvailable=-1
  6.        
  7.         public static method release takes timer time returns nothing
  8.             call PauseTimer(time)
  9.             set maxAvailable=maxAvailable+1
  10.             set availableTimers[maxAvailable]=time
  11.         endmethod
  12.        
  13.         public static method get takes nothing returns timer
  14.             if maxAvailable==-1 then
  15.                 return CreateTimer()
  16.             endif
  17.             set maxAvailable=maxAvailable-1
  18.             return availableTimers[maxAvailable+1]
  19.         endmethod
  20.     endstruct
  21. endlibrary
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement