[input] pthread_cond_wait when no timeout

pull/2166/head
nick black 3 years ago
parent 1d4c62d446
commit 686aac4689
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -1818,6 +1818,9 @@ internal_get(inputctx* ictx, const struct timespec* ts, ncinput* ni){
}
pthread_mutex_lock(&ictx->ilock);
while(!ictx->ivalid){
if(ts == NULL){
pthread_cond_wait(&ictx->icond, &ictx->ilock);
}else{
if(pthread_cond_timedwait(&ictx->icond, &ictx->ilock, ts)){
if(errno == ETIMEDOUT){
return 0;
@ -1826,6 +1829,7 @@ internal_get(inputctx* ictx, const struct timespec* ts, ncinput* ni){
return (uint32_t)-1;
}
}
}
memcpy(ni, &ictx->inputs[ictx->iread], sizeof(*ni));
if(++ictx->iread == ictx->isize){
ictx->iread = 0;
@ -1849,7 +1853,6 @@ uint32_t notcurses_get(notcurses* nc, const struct timespec* ts, ncinput* ni){
int notcurses_getvec(notcurses* n, const struct timespec* ts,
ncinput* ni, int vcount){
for(int v = 0 ; v < vcount ; ++v){
// FIXME need to manage ts; right now, we could delay up to ts * vcount!
uint32_t u = notcurses_get(n, ts, &ni[v]);
if(u == (uint32_t)-1){
if(v == 0){

Loading…
Cancel
Save