views:

38

answers:

1

I am using NSPR as my cross-platform threading library and using these locks: PRLock and PRRWLock. I want a timeout in the lock functions. So that, it should wait for 45 seconds, and if it is not able to acquire a lock within that time, the call should come out with an error.

Then we can report error to the user within 45 seconds.

How can I do it?

Actually I am doing some SQLite operation inside a lock, and sometimes that take long time to complete, if the database is large (~1.9 GB). I want to come up with error to the user that time, if acquiring lock fails. Please help.

A: 

I have not used this lib myself but most waits usually have a time out.

But as I checked the doc real quick I found this for PRLock "Acquiring the lock is not an interruptible operation, nor is there any timeout mechanism.".

https://developer.mozilla.org/en/PR_Lock

Fredrik Jansson