Welcome to the main channel on the development of MoarVM, a virtual machine for NQP and Rakudo (moarvm.org). This channel is being logged for historical purposes.
Set by lizmat on 24 May 2021.
04:04 nebuchadnezzar left 07:35 nebuchadnezzar joined 08:46 vrurg left 10:00 sena_kun joined
lizmat I wonder, could there be a way to create a nqp::op that would return an int for the currently active thread ? 14:02
14:16 vrurg joined
jnthn $ raku -e 'use nqp; say nqp::threadid(nqp::currentthread())' 15:08
1
$ raku -e 'use nqp; await start { say nqp::threadid(nqp::currentthread()) }' 15:09
4
lizmat: Like ^^ ?
[Coke] jnthn++ # Hi! 15:19
japhb \o/ Worth(ington) waiting for 15:47
lizmat jnthn: question: is that cheap or not? 15:53
reason I'm asking is thinking how feasably it would be to make $/ an array under the hood, and use the threadid as an index into it 15:54
probably a bad idea... but still :-)
alternately, being able to insert a "my $/" into a clone of a block at runtime
16:34 [Coke] left 17:58 Voldenet_ joined 17:59 Voldenet left, Voldenet_ is now known as Voldenet 18:07 [Coke] joined 18:12 Voldenet left, Voldenet_ joined, Voldenet_ is now known as Voldenet 18:40 [Coke] left 18:42 [Coke] joined
MasterDuke those are pretty cheap. `my int $a; my int $i := 0; my int $s := nqp::time(); $a := nqp::threadid(nqp::currentthread()) while $i++ < 100_000_000; say(nqp::time() - $s); say($a)` is only about 3.5x longer than `my int $a; my int $i := 0; my int $s := nqp::time(); $a := $i while $i++ < 100_000_000; say(nqp::time() - $s); say($a)` 19:23
ugexe is thread.id safe to reuse like that? i thought it had to be more like nqp::objectid($*THREAD) 20:06
i don't remember why i think that though 20:08
vrurg Best is $*STACK-ID. A thread may change, but that is guaranteed to be unique per call stack. 20:46
ugexe i think the question is if $*THREAD.id can be relied on to always identify the same thread 20:50
vrurg I don't think it makes sense to have $/ bound to a thread because then same callstack could end up using different $/ in the same frame. 20:52
23:22 sena_kun left
lizmat yeah, that's probably a bad idea 23:35
now: inserting a 'my $/' into a cloned block at runtime 23:36