public static bool remove(Closeable c) { lock (closeables) { bool b; if (!closeables.TryGetValue(c, out b)) { return(true); } if (!b) { closeables.Remove(c); Monitor.PulseAll(closeables); return(false); } engineExecutor.execute(() => { lock (closeables) { bool _b; if (!closeables.TryGetValue(c, out _b) || !_b) { return; } closeables.Remove(c); closeables.Add(c, false); } c.close(); }); while (closeables.ContainsKey(c)) { Monitor.Wait(closeables); } return(true); } }
/* * This method @is invoked after a Quercus request has been * processed and the environment @is being cleaned up. * An object that : the EnvCleanup interface * will register itself with via Env.addCleanup() to * ensure that resources are released when the script * has finished executing. If an object's resources * are explicitly cleaned up, the Env.removeCleanup() * method should be invoked. */ public void cleanup() { _obj.close(); }