Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot create a FlowVar[ tuple[a: string] ] #11717

Open
rayman22201 opened this issue Jul 11, 2019 · 6 comments
Open

cannot create a FlowVar[ tuple[a: string] ] #11717

rayman22201 opened this issue Jul 11, 2019 · 6 comments
Labels

Comments

@rayman22201
Copy link
Contributor

Attempting to create a FlowVar[ tuple[ a: string ] ] fails with:
test.nim(6, 15) Error: cannot create a flowVar of type: tuple[a: string]

Creating a FlowVar[string] directly works.
Creating a FlowVar of a tuple with fields of any other type works. Only tuples containing strings seem to fail.

This was discovered by attempting to use execCmdEx() from the OsProc module with spawn.

Example

import threadpool, osproc

proc test(): tuple[a: string] =
  return (a: "flowvar string tuple")

let a = spawn test()

sync()

echo ^a
$ nim -v
Nim Compiler Version 0.20.99 [Linux: amd64]
Compiled at 2019-07-11
Copyright (c) 2006-2019 by Andreas Rumpf

active boot switches: -d:release
@alaviss
Copy link
Collaborator

alaviss commented Jul 12, 2019

it's worth noting that this works with https://github.com/yglukhov/threadpools :)

@Chris3606
Copy link

Chris3606 commented Dec 29, 2020

This still shows up in Nim v1.4.2; is there an intended workaround for this, short of using the linked version of threadpools?

@alaviss
Copy link
Collaborator

alaviss commented Dec 30, 2020

Nope, official threadpool is sorta unmaintained by now. Alternatives includes https://github.com/mratsim/weave and https://github.com/yglukhov/threadpools

@Chris3606
Copy link

Chris3606 commented Dec 30, 2020

Hm. I can definitely work around it or use an alternative for my use case... But for future reference (both for me and those who encounter this issue in the future), given that, are there future plans to remove/replace the current Nim standard library threadpool implementation? Particularly since one of the linked implementations appears to not support gc:arc...

@alaviss
Copy link
Collaborator

alaviss commented Dec 30, 2020

AFAIK weave will be the future. ARC supports will come after we got Isolated[T] in place I think, since it would be much easier to move memory between threads. See nim-lang/RFCs#160 and nim-lang/RFCs#244 and nim-lang/RFCs#295 for the future of Nim's multithreading/async.

@ringabout
Copy link
Member

It seems to work with --gc:arc?

import threadpool

proc test(): tuple[a: string] =
  return (a: "flowvar string tuple")

let a = spawn test()

sync()

echo typeof(a)
echo ^a
FlowVar[tuple[a: string]]
(a: "flowvar string tuple")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants
@rayman22201 @alaviss @Chris3606 @mratsim @ringabout and others