fossil: move from liboventi to libthread and libventi

R=rsc
https://codereview.appspot.com/13504049
This commit is contained in:
David du Colombier 2013-09-23 23:16:25 +02:00
parent 6f4d00ee45
commit 4b57665805
38 changed files with 1360 additions and 1424 deletions

View file

@ -44,7 +44,7 @@ struct WEntry
struct WMap
{
VtLock *lk;
QLock lk;
WEntry *hchild[HashSize];
WEntry *hparent[HashSize];
@ -84,7 +84,7 @@ allocWEntry(void)
w = pool;
if(w == nil){
w = vtMemAllocZ(1024*sizeof(WEntry));
w = vtmallocz(1024*sizeof(WEntry));
for(i=0; i<1024; i++)
freeWEntry(&w[i]);
w = pool;
@ -195,16 +195,15 @@ addChild(uchar p[VtEntrySize], uchar c[VtEntrySize], int off)
void
bwatchReset(uchar score[VtScoreSize])
{
vtLock(map.lk);
qlock(&map.lk);
_bwatchResetParent(score);
_bwatchResetChild(score);
vtUnlock(map.lk);
qunlock(&map.lk);
}
void
bwatchInit(void)
{
map.lk = vtLockAlloc();
wp = privalloc();
*wp = nil;
}
@ -222,7 +221,7 @@ getWThread(void)
w = *wp;
if(w == nil || w->pid != getpid()){
w = vtMemAllocZ(sizeof(WThread));
w = vtmallocz(sizeof(WThread));
*wp = w;
w->pid = getpid();
}
@ -241,7 +240,7 @@ bwatchDependency(Block *b)
if(bwatchDisabled)
return;
vtLock(map.lk);
qlock(&map.lk);
_bwatchResetParent(b->score);
switch(b->l.type){
@ -264,7 +263,7 @@ bwatchDependency(Block *b)
addChild(b->score, b->data+i*VtScoreSize, i);
break;
}
vtUnlock(map.lk);
qunlock(&map.lk);
}
static int
@ -376,7 +375,7 @@ bwatchLock(Block *b)
if(b->part != PartData)
return;
vtLock(map.lk);
qlock(&map.lk);
w = getWThread();
for(i=0; i<w->nb; i++){
if(lockConflicts(w->b[i]->score, b->score)){
@ -385,7 +384,7 @@ bwatchLock(Block *b)
stop();
}
}
vtUnlock(map.lk);
qunlock(&map.lk);
if(w->nb >= MaxLock){
fprint(2, "%d: too many blocks held\n", w->pid);
stop();