Ok, technically reason is not GC per se, but thread-local values cannot be 
accessed from other threads. Also, when cache is full, new items will overwrite 
old items (idea of FIFO ring buffer) and then they will be garbage collected.

Here's a very simplified example that will cause SIGSEGV: 
    
    
    from os import sleep
    type Cache = array[1, string]
    proc put(cache: ptr Cache) = cache[0] = "threadlocalstring"
    var sharedcache: Cache
    var thread: Thread[ptr Cache]
    createThread(thread, put, addr sharedcache)
    sleep(1000) # ensures that put happens here
    echo sharedcache[0]
    
    
    Run

But the good news is that with --gc:arc this program works as expected. 

Reply via email to