|
|
|
|||||
|
Timed Lock for Mutex Class
It would be really great if you could add a timedLock function to the Mutex class. Below is an idea of how it might work for the pthread world.
Code:
inline bool
Mutex::timedLock(const Time& timeout) const
{
timeval tv = Time::now() + timeout;
timespec ts;
ts.tv_sec = tv.tv_sec;
ts.tv_nsec = tv.tv_usec * 1000;
int rc = pthread_mutex_timedlock(&_mutex, &ts);
if (rc != 0 && rc != ETIMEDOUT)
{
if(rc == EDEADLK)
{
throw ThreadLockedException(__FILE__, __LINE__);
}
else
{
throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
}
return (rc == 0);
}
|
|
|||||
|
Quote:
|
|
|||||
|
Good point. You are probably right that in my case that I won't notice a thing. I guess I was just looking for a theoretically most efficient solution without realizing the practical details.
|
|
||||||
|
Quote:
Cheers, Bernard |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| IceGrid lock up/unresponsive | tctimmeh | Help Center | 8 | 01-18-2008 04:54 PM |
| IcePy and The global interpreter lock | rc_hz | Comments | 1 | 10-17-2006 09:50 AM |
| IceUtil::Mutex for C# | amrufon | Help Center | 1 | 09-05-2006 09:35 AM |
| boost::condiition lock Problem | ipek | Help Center | 4 | 03-10-2006 02:31 PM |
| Mutex.h : identifier not found | shimrod | Help Center | 4 | 09-17-2005 09:13 PM |