cps icon indicating copy to clipboard operation
cps copied to clipboard

Forking a continuation requires deepCopy()?

Open zevv opened this issue 4 years ago • 2 comments

The move to inherited objects has made it impossible to properly fork continuations. This is what I did before:

proc fork(c: C): C {.cpsMagic.} =
  let c2 = C()
  c2[] = c[]
  c.evq.push c2
  c

This doesn't work because c2 will now be of the C root type, losing all memory of the original type and its data. Workaround is using deepCopy(), but that'll not work on the JS backend and is disabled by default for --gc:arc

I guess there is no alternative standard way to do this?

zevv avatar Jul 01 '21 11:07 zevv

Not yet, and it's the most critical ~defect~ missing enhancement :smirk: as far as I'm concerned.

disruptek avatar Jul 02 '21 03:07 disruptek

This can be solved coincidentally with #190.

disruptek avatar Sep 17 '21 04:09 disruptek