Single Thread Continuation

Robert Engels rengels at ix.netcom.com
Mon Jul 3 12:42:24 UTC 2023


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.

It is not trivial code but it is straightforward. 

I’ll give you a clue - you need to have a watcher of the weak references that wakes the blocked producer  

> On Jul 3, 2023, at 7:28 AM, Attila Kelemen <attila.kelemen85 at gmail.com> wrote:
> 
> 
> Cristian Lorenzetto <cristian.lorenzetto at gmail.com> ezt írta (időpont: 2023. júl. 3., H, 14:09):
>> SynchronousQueue contains thread locks, , it is not suitable for fibers.  Replace this class with another 
>>> 
> 
> 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).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230703/a4b369c7/attachment.htm>


More information about the loom-dev mailing list