Hey all. I'm working on a simple Key Value LSM tree in Nim as an exercise, and I'm running into some issues. I am looking to make it so that an instantiating an instance of my store will also create a background thread that will invoke its compaction logic on a set interval, but I also want to make sure that if the object gets garbage collected, the thread will recognize this and terminate; in other languages I would use something like a Weak Reference.
Here's an arbitrary example (<https://github.com/eileen-code4fun/LSM-Tree/blob/4f9224f96750ebdcebdddbc7ff7e2fb955b98b51/lsmt.go#L27>) I found of a toy KV LSM tree in Go- this line would start a goroutine (coroutine) for every LSM Tree object. Here's part of my code, where I try to implement weakrefs: <https://gist.github.com/MattAlp/e9b941584188db86d508a12614f3db78>. However, this seems to cause a crash (<https://i.imgur.com/GmrlqXU.png>). Where do I begin implementing this or correcting my implementation?
