Re: [AOLSERVER] mutex try lock?

2007-02-23 Thread John Buckman
On Feb 23, 2007, at 8:31 AM, John Buckman wrote: Should also get around to implementing ns_mutex eval $mutex $script--acquire the mutex, evaluate the script, release the mutex. Catch any Tcl errors and re-throw them. This guarantees that the mutex is unlocked, which avoids the trivial

Re: [AOLSERVER] mutex try lock?

2007-02-23 Thread Tom Jackson
Dossy, The problem described is exactly what ns_cond solves. But what is the problem? Executing code withing a mutex lock which takes meaningful time. Instead with ns_cond, you use a mutex just so you can grab a condition variable, or at least try to grab it, and if not go to sleep and wait.

Re: [AOLSERVER] mutex try lock?

2007-02-23 Thread John Buckman
So, the question becomes: is it better to add -timeout time to all the blocking subcommands, or to add ns_mutex trylock? In theory, -timeout 0 should perform the trylock equivalent. I'd vote for -timeout on all lock requests, as that way I get both the see if lock is available

Re: [AOLSERVER] mutex try lock?

2007-02-23 Thread Michael Andrews
That is how the ns_cache stuff works in 4.5. There is a maxwait flag that can be set when the cache is created. If one thread has the lock (updating the cache) the others will only wait a certain amount of time before timing out - good deadlock prevention. M On Feb 23, 2007, at 10:06

[AOLSERVER] mutex try lock?

2007-02-22 Thread John Buckman
I'm looking to have mutexes with timeouts, and I see support in the C code for this but none carried over to Tcl. In the C code, there's a Ns_MutexTryLock() function, but no tcl function for calling it. Ns_MutexLock calls Ns_MutexTryLock() and there appears to be timeout support: if

Re: [AOLSERVER] mutex try lock?

2007-02-22 Thread Tom Jackson
I have some example code of condition wait: http://rmadilo.com/m2/servers/rmadilo/modules/tcl/twt/packages/db/tcl/datasource-procs.tcl The procs lock, unlock, wait, popPool, etc. Wrap the ideas up pretty easily, but the question is what happens when you code times out waiting for a resource?

Re: [AOLSERVER] mutex try lock?

2007-02-22 Thread John Buckman
Forgot to mention that I know about Dossy's comment in the wiki that nsv_incr can be used to this effect, and I'm doing that. http://panoptic.com/wiki/aolserver/Nsv_incr but I was wondering why try wasn't part of ns_mutex when the C code is there for it. -john On Feb 22, 2007, at 3:09

Re: [AOLSERVER] mutex try lock?

2007-02-22 Thread Nathan Folkman
Just curious, but what's the use case where you would use something like this? - n On 2/22/07, Tom Jackson [EMAIL PROTECTED] wrote: I have some example code of condition wait: http://rmadilo.com/m2/servers/rmadilo/modules/tcl/twt/packages/db/tcl/datasource-procs.tcl The procs lock, unlock,