mirror of
https://gitee.com/acl-dev/acl.git
synced 2024-12-02 03:47:53 +08:00
fixed bugs in fiber_sem.c/fiber_lock.c
This commit is contained in:
parent
0c89422256
commit
0ffeedfcd4
@ -105,6 +105,7 @@ void acl_fiber_mutex_unlock(ACL_FIBER_MUTEX *lk)
|
||||
if ((lk->owner = ready) != NULL) {
|
||||
ring_detach(&ready->me);
|
||||
acl_fiber_ready(ready);
|
||||
acl_fiber_yield();
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,12 +201,14 @@ void acl_fiber_rwlock_runlock(ACL_FIBER_RWLOCK *lk)
|
||||
ring_detach(&lk->wwaiting);
|
||||
lk->writer = fiber;
|
||||
acl_fiber_ready(fiber);
|
||||
acl_fiber_yield();
|
||||
}
|
||||
}
|
||||
|
||||
void acl_fiber_rwlock_wunlock(ACL_FIBER_RWLOCK *lk)
|
||||
{
|
||||
ACL_FIBER *fiber;
|
||||
size_t n = 0;
|
||||
|
||||
if (lk->writer == NULL)
|
||||
msg_fatal("%s(%d), %s: wunlock: not locked",
|
||||
@ -221,11 +224,16 @@ void acl_fiber_rwlock_wunlock(ACL_FIBER_RWLOCK *lk)
|
||||
ring_detach(&lk->rwaiting);
|
||||
lk->readers++;
|
||||
acl_fiber_ready(fiber);
|
||||
n++;
|
||||
}
|
||||
|
||||
if (lk->readers == 0 && (fiber = FIRST_FIBER(&lk->wwaiting)) != NULL) {
|
||||
ring_detach(&lk->wwaiting);
|
||||
lk->writer = fiber;
|
||||
acl_fiber_ready(fiber);
|
||||
n++;
|
||||
}
|
||||
|
||||
if (n > 0)
|
||||
acl_fiber_yield();
|
||||
}
|
||||
|
@ -102,11 +102,13 @@ int acl_fiber_sem_post(ACL_FIBER_SEM *sem)
|
||||
|
||||
if ((ready = FIRST_FIBER(&sem->waiting)) == NULL) {
|
||||
sem->num++;
|
||||
acl_fiber_yield();
|
||||
return sem->num;
|
||||
}
|
||||
|
||||
ring_detach(&ready->me);
|
||||
acl_fiber_ready(ready);
|
||||
|
||||
acl_fiber_yield();
|
||||
return sem->num;
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
|
||||
107) 2019.5.16
|
||||
107.1) bugifx: fiber_sem.c/fiber_lock.c 当释放资源时,应该先让出来调度权,以便于
|
||||
等待者获得被调度机会
|
||||
|
||||
106) 2019.5.9
|
||||
106.1) safety & feature: 为防止用错,对于一些类增加了禁止拷贝复制限制
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user