× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



John, IN has the *LOCK option for data areas.

I'm sure you already knew that. :)

Brad
www.bvstools.com

On Wed, Oct 15, 2014 at 9:55 AM, John Yeung <gallium.arsenide@xxxxxxxxx>
wrote:

On Wed, Oct 15, 2014 at 10:15 AM, Bradley Stone <bvstone@xxxxxxxxx> wrote:
I quit using anything timestamp related for temp file names years ago
when
collisions started happening. Not often, but they did.

Depending on the application, the timestamp (to the microsecond) can
still be a useful and easy way to generate *part of* a unique
identifier. I want to stress "depending on the application". (After
all, for some applications, just a simple date is already enough!)
And also to stress "part of". I would think there are plenty of
applications where timestamp combined with job info provides plenty of
uniqueness.

Now I just create a data area for my application and create a function to
get the next ID (ie, read in the data area value, lock it, add one to it,
then unlock it).

For maximum robustness and simplicity, shouldn't acquiring the lock
happen first, before even reading it? In other words, don't you have
to guard against

JobA - reads 39
JobB - reads 39
JobA - gets lock
JobA - sets value to 39+1
JobA - releases lock
JobB - gets lock
JobB - sets value to 39+1
JobB - releases lock

John Y.
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L)
mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.