IPC-ScoreBoard
view release on metacpan or search on metacpan
ScoreBoard.xs view on Meta::CPAN
}
OUTPUT:
RETVAL
IV
incr(sb, slot, idx, amount=1)
SV* sb
UV slot
UV idx
IV amount
PROTOTYPE: $$$;$
INIT:
UV sz;
vIV *slotptr=get_slot(sb, slot, &sz);
CODE:
if( expect_true(idx<sz) ) {
RETVAL=atomic_add(&slotptr[idx], amount);
} else {
croak("index within slot out of range");
}
OUTPUT:
RETVAL
IV
decr(sb, slot, idx, amount=1)
SV* sb
UV slot
UV idx
IV amount
PROTOTYPE: $$$;$
INIT:
UV sz;
vIV *slotptr=get_slot(sb, slot, &sz);
CODE:
if( expect_true(idx<sz) ) {
RETVAL=atomic_sub(&slotptr[idx], amount);
} else {
croak("index within slot out of range");
}
OUTPUT:
RETVAL
IV
sum(sb, idx)
SV* sb
UV idx
PROTOTYPE: $$
CODE:
RETVAL=sum(sb, idx);
OUTPUT:
RETVAL
void
get_all(sb, slot)
SV* sb
UV slot
PROTOTYPE: $$
INIT:
UV sz, i;
vIV *slotptr=get_slot(sb, slot, &sz);
PPCODE:
EXTEND(SP, sz);
for( i=0; i<sz; i++ ) {
mPUSHi(slotptr[i]);
}
void
sum_all(sb)
SV* sb
PROTOTYPE: $
PPCODE:
if( expect_true((sb && SvROK(sb))) ) {
struct hdr *hdr=(struct hdr *)SvPV_nolen(SvRV(sb));
vIV *data=(vIV*)(sizeof(*hdr)+(char*)hdr);
UV i, j;
EXTEND(SP, hdr->slotsize);
for( j=0; j<hdr->slotsize; j++ ) {
mPUSHi(0);
}
for( i=0; i<hdr->how_many; i++ ) {
for( j=0; j<hdr->slotsize; j++ ) {
SvIV_set(ST(j), SvIVX(ST(j))+data[i*hdr->slotsize+j]);
}
}
} else {
croak("invalid scoreboard parameter");
}
IV
get_extra(sb, idx=0)
SV* sb
UV idx
PROTOTYPE: $;$
INIT:
UV sz;
vIV *slotptr=get_extra(sb, &sz);
CODE:
if( expect_true(idx<sz) ) {
RETVAL=slotptr[idx];
} else {
croak("index within extra slot out of range");
}
OUTPUT:
RETVAL
IV
set_extra(sb, idx, val)
SV* sb
UV idx
IV val
PROTOTYPE: $$$
INIT:
UV sz;
vIV *slotptr=get_extra(sb, &sz);
CODE:
if( expect_true(idx<sz) ) {
RETVAL=slotptr[idx]=val;
} else {
croak("index within extra slot out of range");
}
OUTPUT:
RETVAL
IV
incr_extra(sb, idx, amount=1)
SV* sb
UV idx
IV amount
PROTOTYPE: $$;$
INIT:
UV sz;
vIV *slotptr=get_extra(sb, &sz);
CODE:
if( expect_true(idx<sz) ) {
RETVAL=atomic_add(&slotptr[idx], amount);
} else {
croak("index within extra slot out of range");
}
OUTPUT:
RETVAL
IV
decr_extra(sb, idx, amount=1)
SV* sb
UV idx
IV amount
PROTOTYPE: $$;$
INIT:
UV sz;
vIV *slotptr=get_extra(sb, &sz);
CODE:
if( expect_true(idx<sz) ) {
RETVAL=atomic_sub(&slotptr[idx], amount);
} else {
croak("index within extra slot out of range");
}
OUTPUT:
RETVAL
void
get_all_extra(sb)
SV* sb
PROTOTYPE: $
INIT:
UV sz, i;
vIV *slotptr=get_extra(sb, &sz);
PPCODE:
EXTEND(SP, sz);
for( i=0; i<sz; i++ ) {
mPUSHi(slotptr[i]);
}
IV
have_atomics()
PROTOTYPE:
CODE:
RETVAL=HAVE_ATOMICS;
OUTPUT:
RETVAL
IV
offset_of(sb, slot, idx=0)
SV* sb
UV slot
UV idx
PROTOTYPE: $$;$
CODE:
RETVAL=-1;
if( expect_true((sb && SvROK(sb))) ) {
struct hdr *hdr=(struct hdr *)SvPV_nolen(SvRV(sb));
IV *data=(IV*)(sizeof(*hdr)+(char*)hdr);
if( expect_true(items>2 && SvOK(ST(2))) ) {
/* fetch slot offset */
if( expect_true(slot<hdr->how_many) ) {
if( expect_true(idx<hdr->slotsize) ) {
RETVAL=(char*)&data[slot*hdr->slotsize+idx] - (char*)hdr;
} else {
croak("index within extra slot out of range");
}
} else {
croak("slot number out of range");
}
} else {
/* fetch extra offset */
if( expect_true(slot<hdr->extra) ) {
RETVAL=(char*)&data[hdr->how_many*hdr->slotsize+slot] - (char*)hdr;
} else {
croak("index within extra slot out of range");
}
}
}
OUTPUT:
RETVAL
## Local Variables:
## mode: C
## End:
( run in 1.264 second using v1.01-cache-2.11-cpan-71847e10f99 )