WatchDirectory Forum
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl
watchDirectory forums >> How to... >> wait for resources looping
http://www.watchdirectory.net/cgi-bin/yabb25/YaBB.pl?num=1123046863

Message started by kenwshmt on Aug 3rd, 2005 at 7:27am

Title: wait for resources looping
Post by kenwshmt on Aug 3rd, 2005 at 7:27am
I am using version 3.2, as 4 doesn't have the 'don't wait for close'

I have it set to launch several instances of the batch, but it will often launch so many that the system will run out of resources and stall until the others finish.

I am thinking of incorporating a wait loop.

this is what ive thought of, but havnt implemented yet.

batch starts-
if counter file 4 exists, rename to counter 5
if counter file 3 exists, rename to counter 4
if counter file 2 exists, rename to counter 3
if counter file 1 exists, rename to counter 2

call busyloop

normal batch
goto :end

:busyloop
if not exist counter 5 goto EOF
goto :busyloop

:end
if counter file 2 exists, rename to counter 1
if counter file 3 exists, rename to counter 2
if counter file 4 exists, rename to counter 3
if counter file 5 exists, rename to counter 4

--

i think the batches perform ok when about 5 are running, the rest can be going in the loops until resources recover some.


Title: Re: wait for resources looping
Post by Gert on Aug 3rd, 2005 at 7:43am
Not a good idea to implement a busy-loop like that, how about this one:

:busyloop
rem sleep 3 seconds without consuming cpu
"%WD_INSTDIR%\gdputil.exe" -sleep 3
etcetera

gdputil is described here: http://www.watchdirectory.net/watchDir/GdPUtil.html.

Your "rename thing" will also be a problem when multiple .bat's are renaming at the same time.

I seem to have misplaced my thinking cap, but maybe you can use the "-join" described on the above gdputil page.

Gert

Title: Re: wait for resources looping
Post by Gert on Aug 3rd, 2005 at 3:50pm
This is, obviously, completely coincidential, but "Do not wait for .bat file to exit" and "allow ? .bat files max to run at the same time" have been implemented in version 4.

http://www.watchdirectory.net/wdhelp/help/wdcc_version_history.html
http://www.watchdirectory.net/wdhelp/plugins/wdopAutoRunBat.html

Gert

WatchDirectory Forum » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2017. All Rights Reserved.