本文整理汇总了C++中propagatemark函数的典型用法代码示例。如果您正苦于以下问题:C++ propagatemark函数的具体用法?C++ propagatemark怎么用?C++ propagatemark使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了propagatemark函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: singlestep
static l_mem singlestep (lua_State *L) {
global_State *g = G(L);
switch (g->gcstate) {
case GCSpause: {
if (!isgenerational(g))
markroot(g); /* start a new collection */
/* in any case, root must be marked */
lua_assert(!iswhite(obj2gco(g->mainthread))
&& !iswhite(gcvalue(&g->l_registry)));
g->gcstate = GCSpropagate;
return GCROOTCOST;
}
case GCSpropagate: {
if (g->gray)
return propagatemark(g);
else { /* no more `gray' objects */
g->gcstate = GCSatomic; /* finish mark phase */
atomic(L);
return GCATOMICCOST;
}
}
case GCSsweepstring: {
if (g->sweepstrgc < g->strt.size) {
sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
return GCSWEEPCOST;
}
else { /* no more strings to sweep */
g->sweepgc = &g->finobj; /* prepare to sweep finalizable objects */
g->gcstate = GCSsweepudata;
return 0;
}
}
case GCSsweepudata: {
if (*g->sweepgc) {
g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
return GCSWEEPMAX*GCSWEEPCOST;
}
else {
g->sweepgc = &g->allgc; /* go to next phase */
g->gcstate = GCSsweep;
return GCSWEEPCOST;
}
}
case GCSsweep: {
if (*g->sweepgc) {
g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
return GCSWEEPMAX*GCSWEEPCOST;
}
else {
/* sweep main thread */
GCObject *mt = obj2gco(g->mainthread);
sweeplist(L, &mt, 1);
checkSizes(L);
g->gcstate = GCSpause; /* finish collection */
return GCSWEEPCOST;
}
}
default: lua_assert(0); return 0;
}
}
开发者ID:alucard-dracula,项目名称:yggdrasil,代码行数:60,代码来源:lgc.c
示例2: singlestep
static lu_mem singlestep (lua_State *L) {
global_State *g = G(L);
switch (g->gcstate) {
case GCSpause: {
g->GCmemtrav = g->strt.size * sizeof(GCObject*);
restartcollection(g);
g->gcstate = GCSpropagate;
return g->GCmemtrav;
}
case GCSpropagate: {
g->GCmemtrav = 0;
lua_assert(g->gray);
propagatemark(g);
if (g->gray == NULL) /* no more gray objects? */
g->gcstate = GCSatomic; /* finish propagate phase */
return g->GCmemtrav; /* memory traversed in this step */
}
case GCSatomic: {
lu_mem work;
int sw;
propagateall(g); /* make sure gray list is empty */
work = atomic(L); /* work is what was traversed by 'atomic' */
sw = entersweep(L);
g->GCestimate = gettotalbytes(g); /* first estimate */;
return work + sw * GCSWEEPCOST;
}
case GCSswpallgc: { /* sweep "regular" objects */
return sweepstep(L, g, GCSswpfinobj, &g->finobj);
}
case GCSswpfinobj: { /* sweep objects with finalizers */
return sweepstep(L, g, GCSswptobefnz, &g->tobefnz);
}
case GCSswptobefnz: { /* sweep objects to be finalized */
return sweepstep(L, g, GCSswpend, NULL);
}
case GCSswpend: { /* finish sweeps */
makewhite(g, g->mainthread); /* sweep main thread */
checkSizes(L, g);
g->gcstate = GCScallfin;
return 0;
}
case GCScallfin: { /* call remaining finalizers */
if (g->tobefnz && g->gckind != KGC_EMERGENCY) {
int n = runafewfinalizers(L);
return (n * GCFINALIZECOST);
}
else { /* emergency mode or no more finalizers */
g->gcstate = GCSpause; /* finish collection */
return 0;
}
}
default:
lua_assert(0);
return 0;
}
}
开发者ID:scw000000,项目名称:Engine,代码行数:56,代码来源:lgc.c
示例3: singlestep
static l_mem singlestep(lua_State *L) {
global_State *g = G(L);
/*lua_checkmemory(L);*/
switch (g->gcstate) {
case GCSpause: {
markroot(L); /* start a new collection */
return 0;
}
case GCSpropagate: {
if (g->gray)
return propagatemark(g);
else { /* no more `gray' objects */
atomic(L); /* finish mark phase */
return 0;
}
}
case GCSsweepstring: {
lu_mem old = g->totalbytes;
sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */
g->gcstate = GCSsweep; /* end sweep-string phase */
lua_assert(old >= g->totalbytes);
g->estimate -= old - g->totalbytes;
return GCSWEEPCOST;
}
case GCSsweep: {
lu_mem old = g->totalbytes;
g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
if (*g->sweepgc == NULL) { /* nothing more to sweep? */
checkSizes(L);
g->gcstate = GCSfinalize; /* end sweep phase */
}
lua_assert(old >= g->totalbytes);
g->estimate -= old - g->totalbytes;
return GCSWEEPMAX * GCSWEEPCOST;
}
case GCSfinalize: {
if (g->tmudata) {
GCTM(L);
if (g->estimate > GCFINALIZECOST)
g->estimate -= GCFINALIZECOST;
return GCFINALIZECOST;
} else {
g->gcstate = GCSpause; /* end collection */
g->gcdept = 0;
return 0;
}
}
default:
lua_assert(0);
return 0;
}
}
开发者ID:wayling,项目名称:xboot-clone,代码行数:53,代码来源:lgc.c
示例4: singlestep
// lua的gc状态机,执行顺序和下面的状态的从大到小开始一致
static l_mem singlestep (lua_State *L) {
global_State *g = G(L);
/*lua_checkmemory(L);*/
switch (g->gcstate) {
case GCSpause: {// 初始状态
markroot(L); /* start a new collection */// 主要就是标记主线程对象(也就是从白色染成灰色)
return 0;
}
case GCSpropagate: {// 这个状态也是一个标记过程,并且会被进入多次,也就是分布迭代
if (g->gray)// 如果gray对象一直存在的话,反复调用propagatemark函数,等所有的gray对象都被标记了,就会进入atomic函数处理
return propagatemark(g);
else { /* no more `gray' objects */
atomic(L); /* finish mark phase */// 原子操作
return 0;
}
}
case GCSsweepstring: {// 清理字符串的阶段
lu_mem old = g->totalbytes;
sweepwholelist(L, &g->strt.hash[g->sweepstrgc++]);
if (g->sweepstrgc >= g->strt.size) /* nothing more to sweep? */
g->gcstate = GCSsweep; /* end sweep-string phase */
lua_assert(old >= g->totalbytes);
g->estimate -= old - g->totalbytes;
return GCSWEEPCOST;
}
case GCSsweep: {
lu_mem old = g->totalbytes;
g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
if (*g->sweepgc == NULL) { /* nothing more to sweep? */
checkSizes(L);
g->gcstate = GCSfinalize; /* end sweep phase */
}
lua_assert(old >= g->totalbytes);
g->estimate -= old - g->totalbytes;
return GCSWEEPMAX*GCSWEEPCOST;
}
case GCSfinalize: {
if (g->tmudata) {
GCTM(L);
if (g->estimate > GCFINALIZECOST)
g->estimate -= GCFINALIZECOST;
return GCFINALIZECOST;
}
else {
g->gcstate = GCSpause; /* end collection */
g->gcdept = 0;
return 0;
}
}
default: lua_assert(0); return 0;
}
}
开发者ID:great90,项目名称:LuaSrcNote,代码行数:53,代码来源:lgc.c
示例5: propagateall
static size_t propagateall (global_State *g) {
size_t m = 0;
while (g->gray) m += propagatemark(g);
return m;
}
开发者ID:VargMon,项目名称:netbsd-cvs-mirror,代码行数:5,代码来源:lgc.c
示例6: propagateall
static void propagateall (global_State *g) {
while (g->gray) propagatemark(g);
}
开发者ID:charleeli,项目名称:srpc,代码行数:3,代码来源:lgc.c
示例7: singlestep
static lu_mem singlestep (lua_State *L) {
global_State *g = G(L);
switch (g->gcstate) {
case GCSpause: {
/* start to count memory traversed */
g->GCmemtrav = g->strt.size * sizeof(GCObject*);
lua_assert(!isgenerational(g));
restartcollection(g);
g->gcstate = GCSpropagate;
return g->GCmemtrav;
}
case GCSpropagate: {
if (g->gray) {
lu_mem oldtrav = g->GCmemtrav;
propagatemark(g);
return g->GCmemtrav - oldtrav; /* memory traversed in this step */
}
else { /* no more `gray' objects */
lu_mem work;
int sw;
g->gcstate = GCSatomic; /* finish mark phase */
g->GCestimate = g->GCmemtrav; /* save what was counted */;
work = atomic(L); /* add what was traversed by 'atomic' */
g->GCestimate += work; /* estimate of total memory traversed */
sw = entersweep(L);
return work + sw * GCSWEEPCOST;
}
}
case GCSsweepstring: {
int i;
for (i = 0; i < GCSWEEPMAX && g->sweepstrgc + i < g->strt.size; i++)
sweepwholelist(L, &g->strt.hash[g->sweepstrgc + i]);
g->sweepstrgc += i;
if (g->sweepstrgc >= g->strt.size) /* no more strings to sweep? */
g->gcstate = GCSsweepudata;
return i * GCSWEEPCOST;
}
case GCSsweepudata: {
if (g->sweepfin) {
g->sweepfin = sweeplist(L, g->sweepfin, GCSWEEPMAX);
return GCSWEEPMAX*GCSWEEPCOST;
}
else {
g->gcstate = GCSsweep;
return 0;
}
}
case GCSsweep: {
if (g->sweepgc) {
g->sweepgc = sweeplist(L, g->sweepgc, GCSWEEPMAX);
return GCSWEEPMAX*GCSWEEPCOST;
}
else {
/* sweep main thread */
GCObject *mt = obj2gco(g->mainthread);
sweeplist(L, &mt, 1);
checkSizes(L);
g->gcstate = GCSpause; /* finish collection */
return GCSWEEPCOST;
}
}
default: lua_assert(0); return 0;
}
}
开发者ID:crazii,项目名称:mameplus,代码行数:64,代码来源:lgc.c
注:本文中的propagatemark函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论