<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div dir="ltr"></div><div dir="ltr">The code is not correct. Read about reference queues and weak references and how you could have the producer detect when there are no more possible readers and clean itself up. You don’t need to provide a cleaner - it can all be done internal to the “generator” implementation.</div><div dir="ltr"><br></div><div dir="ltr">It is not trivial code but it is straightforward. </div><div dir="ltr"><br></div><div dir="ltr">I’ll give you a clue - you need to have a watcher of the weak references that wakes the blocked producer </div><div dir="ltr"><br><blockquote type="cite">On Jul 3, 2023, at 7:28 AM, Attila Kelemen <attila.kelemen85@gmail.com> wrote:<br><br></blockquote></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div dir="ltr">Cristian Lorenzetto <<a href="mailto:cristian.lorenzetto@gmail.com">cristian.lorenzetto@gmail.com</a>> ezt írta (időpont: 2023. júl. 3., H, 14:09):<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">SynchronousQueue contains thread locks, , it is not suitable for fibers. Replace this class with another <br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div><br></div></div></div></blockquote></div></blockquote><div><br></div><div>Aside from this class just being an example on how such a code would look like, I don't see why `SynchronousQueue` is "not suitable for fibers". Locks work perfectly well with VT, and even `synchronized` does, if it only does some simple computation in a `synchronized` block (since it wouldn't be unmounted anyway).</div></div></div>
</div></blockquote></body></html>