MCPcopy Create free account
hub / github.com/csound/csound / csoundWaitThreadLock

Function csoundWaitThreadLock

Top/threads.c:253–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253PUBLIC int csoundWaitThreadLock(void *lock, size_t milliseconds)
254{
255 {
256 register int retval = pthread_mutex_trylock((pthread_mutex_t*) lock);
257 if (!retval)
258 return retval;
259 if (!milliseconds)
260 return retval;
261 }
262 {
263 struct timeval tv;
264 struct timespec ts;
265 register size_t n, s;
266
267#ifndef HAVE_GETTIMEOFDAY
268 gettimeofday_(&tv, NULL);
269#else
270 gettimeofday(&tv, NULL);
271#endif
272
273 s = milliseconds / (size_t) 1000;
274 n = milliseconds - (s * (size_t) 1000);
275 s += (size_t) tv.tv_sec;
276 n = (size_t) (((int) n * 1000 + (int) tv.tv_usec) * 1000);
277 ts.tv_nsec = (long) (n < (size_t) 1000000000 ? n : n - 1000000000);
278 ts.tv_sec = (time_t) (n < (size_t) 1000000000 ? s : s + 1);
279 return pthread_mutex_timedlock((pthread_mutex_t*) lock, &ts);
280 }
281
282}
283
284PUBLIC void csoundWaitThreadLockNoTimeout(void *lock)
285{

Callers 11

PerformMethod · 0.85
QueueMessageMethod · 0.85
LockMethod · 0.85
TryLockMethod · 0.85
CsoundThreadLockMethod · 0.85
LockMethod · 0.85
TryLockMethod · 0.85
CsoundThreadLockMethod · 0.85
LockMethod · 0.85
TryLockMethod · 0.85
CsoundThreadLockMethod · 0.85

Calls 1

gettimeofday_Function · 0.85

Tested by

no test coverage detected