> If there is no reference to the tasklet,

There _is_ a reference (count) to the tasklet, because
PyStackless_GetCurrent() calls Py_INCREF on its return value (I had a
look at the Stackless source code).

What I'm worried about is that even though Py_INCREF has been called,
the garbage collector may free() the tasklet somehow, since it's not
reachable from the root objects -- or is it? Does the local variable
`tasklet' on the C stack of MyFunction (even when switched out)
qualify as a root object, thus protecting the tasklet from being freed
by the garbage collector?

> how do you expect to restart it?

event_set() registers a callback, which gets called later at some
point with the argument (void*)tasklet. That callback will call
PyTasklet_Insert(tasklet).

> Looking at your code, obviously the call to event_set(), if it is to store 
> the tasklet for later wakeup,
> must do a Py_INCREF() on it.   Anyone intending to store a reference must 
> Incref.

I understand this. But isn't the Py_INCREF called by
PyStackless_GetCurrent() enough? As far as I understand, a PY_INCREF
is enough to protect the object from being free()ed by reference
counting. But how does the object get protected from being free()ed by
the garbage collector?

_______________________________________________
Stackless mailing list
[email protected]
http://www.stackless.com/mailman/listinfo/stackless

Reply via email to