[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Guile GC in C++
From: |
Jonas Hahnfeld |
Subject: |
Re: Guile GC in C++ |
Date: |
Tue, 06 Jul 2021 20:13:15 +0200 |
User-agent: |
Evolution 3.40.2 |
Am Dienstag, dem 06.07.2021 um 17:03 +0200 schrieb David Kastrup:
> Jean Abou Samra <jean@abou-samra.fr> writes:
>
> > For example, if I were the author of the below code, how
> > would I understand that the mmrest_event_ should be
> > unprotected?
> >
> > void
> > Part_combine_iterator::kill_mmrest (Context *c)
> > {
> > if (!mmrest_event_)
> > {
> > mmrest_event_ = new Stream_event
> > (Lily::ly_make_event_class (ly_symbol2scm ("multi-measure-rest-event")));
> > set_property (mmrest_event_, "duration", SCM_EOL);
> > mmrest_event_->unprotect ();
> > }
> >
> > c->event_source ()->broadcast (mmrest_event_);
> > }
>
> Uh, after the call to mmrest_event_->unprotect () there is nothing that
> would protect the newly created mmrest_event_ .
Sure there is, the snippet is just too small to show the marking:
void
Part_combine_iterator::derived_mark () const
{
Simultaneous_music_iterator::derived_mark ();
if (mmrest_event_)
scm_gc_mark (mmrest_event_->self_scm ());
}
The code makes perfect sense: If mmrest_event_ isn't set yet, the block
will allocate and unprotect a new object so that before the broadcast,
there is an event under the control of the iterator object for all
possible flows through the function.
signature.asc
Description: This is a digitally signed message part