|
Bruce, > Whats the best way in tems of efficiency and CPU perfomance >to run a CL PGM every 30 min (for instance) or other interval. > Silvio. > >>Nick.England@catalyst-solutions.com wrote: >> >> I guess this is for a polling job or a data feed.. >> >> Could you not send data to a data Q to trigger a job waiting on data to >> arrive in the queue...this will take up no processing time until data >> arrives.. >> >>> >>>Close. Just create a data queue. Call the QRCVDTAQ >>>command with a 30 second wait period. At the end of 30 >>>seconds, the receive program will return to your CL >>>program. Do what you need and then loop back to the >>>QRCVDTAQ call. >>> >>>PGM >>>DCL &data *char 1 >>>DCL &datalen *dec (5 0) >>>DCL &wait *dec (5 0) value(30) >>> >>>@LOOP: call qrcvdtaq('dqname' 'dqlibrary' &datalen &data &wait) >>> . >>> . >>> goto @loop >>>ENDPGM >>> >>>Why loop? It prevents having to start and stop the job >>>every 30 seconds. Saves resource, performs better. >>> >>>Note that the variable &datalen will always return 0 (zero) >>>as there is no data actually received. This could be used >>>as a way to terminate the program. Send data to the data >>>queue and leave the loop if the length is greater than 0. >>> >>>R. Bruce Hoffman, Jr. You are a godsend, my friend. This is a perfect example of the decision-making that goes into solving a business problem. We don't know Silvio's actual business problem, so we've been working with the computer problem: how to efficiently process a lock "real time clock" loop. The "obvious" answer was DLYJOB, for Bruce's reasons: we create a single job a day as opposed to 48 (or more!) Nick proposed the data queue idea, which was refined by Bruce, but now we're using a side-effect (the delay caused by waiting for a message) instead of the primary use (receive a message) and another object (the *PGM and the *DTAQ) This solution has an advantage: it's almost self-terminating. Write a quick CL program to send a message to this queue and it terminates gracefully. The disadvantage is that it relies on a side-effect. If this solution is chosen, it should be heavily commented to note that fact. Bruce's commentary would be perfect. Without any comments, which version's intent (let time elapse without tying up the processor) is clearer? The data queue or @LOOP: DlyJob Dly(&WaitSecs) RtvJobA EndSts(&EndFlag) If (&EndFlag *eq '1') (Goto Terminate) . Goto @LOOP Terminate: Note that each snippet has advantages and disadvantages, and that both will work equally efficiently (the only criteria Silvio gave us.) I'm only talking about how easy it is to figure intent from the code (with the supposition that clearer intent means easier to work on code.) With such a small function, it's pretty easy to wrap your head around either version, but you get the idea. Buck Calabro Aptis; Albany, NY mailto:Buck.Calabro@aptissoftware.com +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
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.