nim-works / loony

A high throughput MPMC lock-free queue based on a paper by Giersch, Nolte et al implemented in pure Nim.
https://nim-works.github.io/loony/
MIT License
64 stars 4 forks source link

Example code errors #11

Closed Vaipex closed 2 years ago

Vaipex commented 2 years ago

Hi, I tried to use the example code from the readme (https://github.com/nim-works/loony#how-to-use) but I got some errors

Hint: used config file '/home/---/.choosenim/toolchains/nim-#devel/config/nim.cfg' [Conf] Hint: used config file '/home/---/.choosenim/toolchains/nim-#devel/config/config.nims' [Conf] ................................................................ /home/---/Desktop/Nim/test.nim(10, 11) template/generic instantiation ofpushfrom here /home/---/.nimble/pkgs/loony-0.1.1/loony.nim(177, 27) template/generic instantiation offetchIncTailfrom here /home/---/.nimble/pkgs/loony-0.1.1/loony.nim(71, 26) Error: attempting to call undeclared routine: 'fetchAdd'

This happens both on the 0.1.0 and 0.1.1

shayanhabibi commented 2 years ago

Hi! Can I confirm the version of nim you are using?

disruptek commented 2 years ago

I think that error message is consistent with loony being built outside gc:arc or gc:orc. It only supports those memory managers at the moment.

shayanhabibi commented 2 years ago

From the error you have provided it appears that you do not have the std/atomics fetchAdd proc in your scope. Judging from the code of atomics https://github.com/nim-lang/Nim/blob/devel/lib/system/atomics.nim it would seem that the operation will only be available when compiled with —threads:on

Please ensure you have the following compiler switches: —gc:arc —threads:on Give it another shot and let us know if there are further issues.

disruptek commented 2 years ago

Yeah, I just came to the same realization. :laughing:

Vaipex commented 2 years ago

Hi, Im using `Nim Compiler Version 1.5.1 [Linux: amd64] Compiled at 2021-09-23 Copyright (c) 2006-2021 by Andreas Rumpf

git hash: 6163bdd279a2c33d4290223cc7f466c8070b8ce4 active boot switches: -d:release`

I already compiled it with nim c --threads:on --gc:arc test.nim still the same error

shayanhabibi commented 2 years ago

Quite odd! Despite the procedures push/pop using the templates, for some reason it required you to import the std/atomics to work. Either way; it has been patched by changing the templates to procedures for now to avoid polluting your name space.

Everything should work with the latest tag.

Thanks :)

Vaipex commented 2 years ago

compiled successfully

shayanhabibi commented 2 years ago

Thanks for letting us know 🙂 if you have questions or ideas give us a shout