Marco,

Have all the phantoms use a function or subroutine to get the next id based on the current system milliseconds. Use a semaphore lock to keep it singleton. Add a "NAP" statement so the next time it's run you're sure to get a different millisecond count -- note that many systems won't give 1ms granularity (IIRC Windows is about 6ms):

      FUNCTION GET.NEXT.ID
*
      EQU MY$SEMAPHORE TO 55
      EQU TD$TICKS LIT '(SYSTEM(99):((SYSTEM(12) * 1000) "R%3"))'
*
      LOCK MY$SEMAPHORE
      MY.ID = TD$TICKS
      NAP 15   ;* must be big enough to get unique id's
      UNLOCK MY$SEMAPHORE
      RETURN (MY.ID)
   END

rex


Marco Manyevere wrote:
What is the most reliable way to generate unique sequential keys without
having to resort to a record on disk updated through readu/write? The keys
don't have to be contiguous but only be sortable in the order in which they
were generated by several phantom processes running concurrently. I'm
currently approximating this using a concatenation of date and time with
millisecondsB but I'm worried about the possibility of two phantoms generating
exactly the same key.
-------
u2-users mailing list
u2-users@listserver.u2ug.org
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to