📄 lock-impl.c
字号:
/* * lock-impl.c - pthread-based LockInterface implementation (Posix style) * * Copyright (c) 1998 * Transvirtual Technologies, Inc. All rights reserved. * * See the file "license.terms" for information on usage and redistribution * of this file. */#include <pthread.h>#include "config.h"#include "config-std.h"#include "gtypes.h"#include "thread.h"#include "lock-impl.h"/* * Wait on the condvar with a given relative timeout in ms (which we * have to convert into a absolute timespec now) */jbooleanjcondvar_wait ( jcondvar* cv, jmutex *mux, jlong timeout ){ nativeThread *cur = GET_CURRENT_THREAD(&cur); int stat; struct timespec abst; struct timeval now; //CHECK_LOCK( cur,lk); cur->stackCur = (void*)&cur; if ( timeout == 0 ) { /* we handle this as "wait forever" */ cur->blockState |= BS_CV; stat = pthread_cond_wait( cv, mux ); cur->blockState &= ~BS_CV; } else { /* timeout is in millisecs, timeval in microsecs, and timespec in nanosecs */ gettimeofday( &now, 0); abst.tv_sec = now.tv_sec + (timeout / 1000); abst.tv_nsec = (now.tv_usec * 1000) + (timeout % 1000) * 1000000; cur->blockState |= BS_CV_TO; stat = pthread_cond_timedwait( cv, mux, &abst); cur->blockState &= ~BS_CV_TO; } return (stat == 0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -