Fork me on GitHub
#off-topic
<
2020-05-23
>
emccue00:05:42

(defn generate-ints []
  (let [c (ArrayBlockingQueue. 1)
        thread (Thread/startVirtualThread
                 (fn []
                   (loop [x 0]
                     (do (.put c x)
                         (recur (inc x))))))]
    (iterator-seq
      (reify Iterator
        (hasNext [_]
          true)
        (next [_]
          (.take c))
        Object
        (finalize [_]
          (.interrupt thread))))))

emccue00:05:54

i was going to ask "is this a proper use of finalize" but i'm decently sure it isn't

hiredman00:05:39

That is interesting, are virtual threads gc roots? They say they are like normal threads which implies they are

hiredman00:05:25

But for example a lot of core.async usage relies on go blocks not being gc roots

emccue01:05:42

hmm, other than the nonsense i just barfed up what usages do you have in mind?

emccue01:05:12

Though yeah, I assume any non-daemon virtual thread (if they could even be daemons) would be a GC root

hiredman01:05:07

Well, for example if a go block is waiting on a channel, because of the inversion of control, the go block is actually a callback on the channel, so if nothing else references the channel (so nothing can unblock the go block away) the channel will be gced

hiredman01:05:21

It is very nice, stops you leaking channels/go blocks

borkdude10:05:38

This is pretty impressive. If you're into CLJS development, you might also find this interesting: https://www.youtube.com/watch?v=HGuTqsVh59w&amp;list=PLA66mD-6yK8yjlJCI0Ay2f2IvvmB9Ktga&amp;index=16

👀 12
lisphug 4
lilactown16:05:32

if there’s performant conditions I’m in

emccue17:05:15

@hiredman Do you know if go does something similar?

emccue17:05:09

that makes me more comfortable at least

emccue17:05:31

i think more is gained from async not being a macro thing than the loss of flexibility

emccue17:05:05

if we match go its a pretty good place

gklijs20:05:16

Brian Goetz discussing Clojure https://www.twitch.tv/nipafx 🙂

Parenoid22:05:10

cool stream... but watching it is making me appreciate clojure.

Parenoid22:05:49

when is Goetz on?

gklijs07:05:43

https://www.twitch.tv/videos/629358245?t=14h13m17s is from the recording, right when Goetz started. Basically he really sees Clojure as added value, and he really likes it's not a 'better java' like Scala and Kotlin, with the tradeoffs that come with that from a language design point.

👍 8
gklijs07:05:43
replied to a thread:when is Goetz on?

https://www.twitch.tv/videos/629358245?t=14h13m17s is from the recording, right when Goetz started. Basically he really sees Clojure as added value, and he really likes it's not a 'better java' like Scala and Kotlin, with the tradeoffs that come with that from a language design point.

👍 8