News for hackers. Stuff that matters.
Re:Chris Lattner on garbage collection vs. Automatic Referen... by mojuba on Sunday April 24, 2022 @07:43AM (#31143123)
Yes, you can move your references around to find a suitable place, but how does that solve the problem of lifetime control? How do you guarantee a network resource is alive for as long as you need it under GC, and under ARC?
Re:Chris Lattner on garbage collection vs. Automatic Referen... by SamReidHughes on Sunday April 24, 2022 @05:43PM (#31148618)
By holding a reference to it that is grounded to a GC root i.e. an an ownership chain to a local variable that will dispose of it. Also which can be used to interrupt the background task. So the network connection, callback, etc., are not in a detached cycle.

With the design you're describing -- without the ability to interrupt the background task -- I would bet you tend to get race conditions of one kind or another.