www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - better c fibers

reply Abby <abby gmail.com> writes:
Hi there,
I'm new in dlang I specially like betterC. I was hoping that d 
fibers would be implemented in without using classes, but there 
are not. Is there another way how to use async/await in dlang 
better c?

Thank you for your help
Abby
Sep 21 2021
next sibling parent Imperatorn <johan_forsberg_86 hotmail.com> writes:
On Tuesday, 21 September 2021 at 09:37:30 UTC, Abby wrote:
 Hi there,
 I'm new in dlang I specially like betterC. I was hoping that d 
 fibers would be implemented in without using classes, but there 
 are not. Is there another way how to use async/await in dlang 
 better c?

 Thank you for your help
 Abby
There are no async/await keywords in D yet. Have you tried searching for compatible packages in dub?
Sep 26 2021
prev sibling next sibling parent reply SealabJaster <sealabjaster gmail.com> writes:
On Tuesday, 21 September 2021 at 09:37:30 UTC, Abby wrote:
 ...
I'm not aware of any -betterC package specifically for coroutines. I have some work done in this regard, but sadly the library itself isn't really usable at all so if you want to put in the effort you'd have to probably extract the code out, but that's quite a bit of effort: https://github.com/BradleyChatha/bcstd/tree/master/source/libd/async To make it even more annoying there's also an ASM file you'd have to deal with: https://github.com/BradleyChatha/bcstd/blob/master/source/asm/coroutine.nasm Alternatively you could go for a C coroutine library, which should function *ok-ish*, but not perfect, but would likely be much easier than the above suggestion. Or write your own, as is a common suggestion around here :3 Libaco provides the general gist of how it works: https://github.com/hnes/libaco#proof-of-correctness
Sep 26 2021
parent SealabJaster <sealabjaster gmail.com> writes:
On Sunday, 26 September 2021 at 09:48:58 UTC, SealabJaster wrote:
 ...
I feel I didn't make it clear enough that extracting the code would be way too much effort than its worth, especially since I'm not even sure it runs on Linux. So I really wouldn't suggest going down that route.
Sep 26 2021
prev sibling next sibling parent Dukc <ajieskola gmail.com> writes:
On Tuesday, 21 September 2021 at 09:37:30 UTC, Abby wrote:
 Hi there,
 I'm new in dlang I specially like betterC. I was hoping that d 
 fibers would be implemented in without using classes, but there 
 are not. Is there another way how to use async/await in dlang 
 better c?

 Thank you for your help
 Abby
A C or C++ concurrency library should work. Another option, if you just want fibers but not true concurrency, would be to do some assembly trickery. Probably not too hard if you know assembly, but not very portable. If the reason you're using `-betterC` is targeting asm.js or WebAssembly, you will need to use the JavaScript APIs of your environment for concurrency.
Sep 27 2021
prev sibling parent Kagamin <spam here.lot> writes:
On Tuesday, 21 September 2021 at 09:37:30 UTC, Abby wrote:
 Hi there,
 I'm new in dlang I specially like betterC. I was hoping that d 
 fibers would be implemented in without using classes, but there 
 are not.
On windows you can use the fiber api https://docs.microsoft.com/en-us/windows/win32/procthread/fibers just as you would do in C.
Sep 28 2021