<div dir="ltr">Hi Christof, you are right, it was a bad idea, but the good news is that in the hours since I posted that I managed to get it to work properly. It's been a while since I did data structures manually in C... :-)<div><br></div><div>I went for maintaining a double-linked list of clock_info structures that just stores them as they come in. If the interpreter is reset, or object freed, or we make a cancel-clocks request, that just gets walked with all clocks unset, freed, and the memory for the clock info nodes freed. In normal operation, no extra walking needs to happen as the (not cancelled) callback takes ownership of the pointers and cleans up as part of it's execution. The implementation could certainly be more elegant, but it seems to be robust (not sure I even need the double linking, but it helped me think about it...) I made a fuzzy tester that assaults the object with variable tempo'd delay requests, requests to cancel 1 delay, and requests to cancel all, and resets and I can't make it crash anymore, even recreating the object. Phew!</div><div><br></div><div>Thanks for the help everyone. Will post to the list when the next cut is ready.</div><div><br></div><div>iain</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jun 12, 2021 at 2:28 PM Christof Ressi <<a href="mailto:info@christofressi.com">info@christofressi.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>Hi,</p>
<p>this is a bit of a XY question. The actual problem is about
managing clocks. Let's see if we can find a proper solution.<br>
</p>
<p>I would assume that you are storing the clock(s) alongside the
interpreter instance. If you restart the interpret, unset the
clock(s) with clock_unset(). If you free the instance, free the
clock(s) with clock_free().</p>
<p>If that somehow doesn't work for you, explain the exact problem
and show the code.<br>
</p>
<p>---</p>
<p>> It doesn't need to be unique across the world, just the
local machine</p>
<p>Why would your ID even need to be unique across the whole
machine? I think it should be enough that it's unique within the
app. In that case, you can simply use the memory address of the
interpreter instance itself. In fact, that's how Pd creates the
canvas and object IDs for communicating with the Tcl/Tk GUI app.</p>
<p>Christof<br>
</p>
<div>On 12.06.2021 18:50, Iain Duncan wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hi folks, i'm wrestling away with the schedule
functions for Scheme-for-Pd, and I think I can make things a lot
more reliable if I let every instantiation (or restart) of the
scheme interpreter have a uid of some sort so that on a reset we
can just ignore clocks running out on a previous instance
instead of trying to clean them all up with manual memory
management. (which approach is giving me segfaults because I'm
screwing something up)
<div><br>
</div>
<div>Can anyone tell me what a smart way of getting a unique
identifier would be? It doesn't need to be unique across the
world, just the local machine, so something that was seeded
from system time would be fine. I'm not a Real C Programmer
though, so am not clear what options will just work across all
OS's, without needing to add dependencies.</div>
<div><br>
</div>
<div>thanks!</div>
<div><br>
</div>
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
Pd-dev mailing list
<a href="mailto:Pd-dev@lists.iem.at" target="_blank">Pd-dev@lists.iem.at</a>
<a href="https://lists.puredata.info/listinfo/pd-dev" target="_blank">https://lists.puredata.info/listinfo/pd-dev</a>
</pre>
</blockquote>
</div>
</blockquote></div>