I don't know of an in-memory solution, but you can probably make the command line solution thread safe. (I'm assuming that the calls to gzip generate file names that are unique to each call?)
You could use some type of flag to indicate that gzip is in use and then wait. A good option would be to use a shared transient. When the app needs to run gzip, it would attempt to lock the shared transient first. If a lock was obtained, then the process would run gzip, releasing the lock once gzip had returned. If the lock was not available, then the application would assume that another process was using gzip. It could then wait for the other process to finish, or return to the user. You probably want to create the shared transient when the Jade Node starts up (e.g. a nongui application specified as a serverapp in the INI file) A basic example is below: (I'd build a timeout for a production system in case zgip crashed etc.)
Code: Select all
vars
oGZIPLock : GZIPLock;
begin
oGZIPLock := GZIPLock.firstSharedTransientInstance;
while not tryLock( oGZIPLock, Exclusive_Lock, Session_Duration, 20000 )
// Wait for the lock to clear e.g. another process is running gzip
process.sleep( 1000 );
endwhile;
// Call GZIP now we have a lock
node.createExternalProcess( "","gzip.exe", ... );
epilog
unlock( oGZIPLock );