summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--compiler/spawn.nim2
-rw-r--r--lib/pure/concurrency/threadpool.nim10
-rw-r--r--lib/system/threads.nim9
3 files changed, 15 insertions, 6 deletions
diff --git a/compiler/spawn.nim b/compiler/spawn.nim
index 733ce7732..7980ac434 100644
--- a/compiler/spawn.nim
+++ b/compiler/spawn.nim
@@ -65,7 +65,7 @@ proc addLocalVar(g: ModuleGraph; varSection, varInit: PNode; owner: PSym; typ: P
   vpart.sons[2] = if varInit.isNil: v else: vpart[1]
   varSection.add vpart
   if varInit != nil:
-    if useShallowCopy and typeNeedsNoDeepCopy(typ):
+    if useShallowCopy and typeNeedsNoDeepCopy(typ) or optNimV2 in g.config.globalOptions:
       varInit.add newFastAsgnStmt(newSymNode(result), v)
     else:
       let deepCopyCall = newNodeI(nkCall, varInit.info, 3)
diff --git a/lib/pure/concurrency/threadpool.nim b/lib/pure/concurrency/threadpool.nim
index e5ac09cf6..3ade6b4f2 100644
--- a/lib/pure/concurrency/threadpool.nim
+++ b/lib/pure/concurrency/threadpool.nim
@@ -251,7 +251,10 @@ proc `^`*[T](fv: FlowVar[ref T]): ref T =
   ## Blocks until the value is available and then returns this value.
   blockUntil(fv)
   let src = cast[ref T](fv.data)
-  deepCopy result, src
+  when defined(nimV2):
+    result = src
+  else:
+    deepCopy result, src
   finished(fv)
 
 proc `^`*[T](fv: FlowVar[T]): T =
@@ -259,7 +262,10 @@ proc `^`*[T](fv: FlowVar[T]): T =
   blockUntil(fv)
   when T is string or T is seq:
     let src = cast[T](fv.data)
-    deepCopy result, src
+    when defined(nimV2):
+      result = src
+    else:
+      deepCopy result, src
   else:
     result = fv.blob
   finished(fv)
diff --git a/lib/system/threads.nim b/lib/system/threads.nim
index 682f2cf80..ad1d82be2 100644
--- a/lib/system/threads.nim
+++ b/lib/system/threads.nim
@@ -136,9 +136,12 @@ else:
       when TArg is void:
         thrd.dataFn()
       else:
-        var x: TArg
-        deepCopy(x, thrd.data)
-        thrd.dataFn(x)
+        when defined(nimV2):
+          thrd.dataFn(thrd.data)
+        else:
+          var x: TArg
+          deepCopy(x, thrd.data)
+          thrd.dataFn(x)
     finally:
       afterThreadRuns()