Starting and managing threads

2023-03-24 Thread Vino via Digitalmars-d-learn
https://forum.dlang.org/post/eeqqmlojlniiihgyb...@forum.dlang.org On Sunday, 16 January 2022 at 09:38:52 UTC, Bagomot wrote: The program does nothing probably because of that continue. (?) No, it does work inside the loop. So, the event loop is in a separate thread. What should happen when t

Re: Starting and managing threads

2022-01-16 Thread forkit via Digitalmars-d-learn
On Monday, 27 December 2021 at 10:59:07 UTC, Ali Çehreli wrote: ...my DConf Online 2020 presentation here: https://dconf.org/2020/online/#ali1 Ali Hey, that is a really great presentation! Many more people should watch it, and learn ;-)

Re: Starting and managing threads

2022-01-16 Thread Bagomot via Digitalmars-d-learn
The program does nothing probably because of that continue. (?) No, it does work inside the loop. So, the event loop is in a separate thread. What should happen when the events trigger? Do you want this thread to handle the events or should this thread send a > message to the main thread (or

Re: Starting and managing threads

2022-01-15 Thread Ali Çehreli via Digitalmars-d-learn
On 1/12/22 00:50, Bagomot wrote: > If I change the run method of the Guard class so that it starts a new > thread, the program just does nothing: > ```d > public void run() { > spawn((shared EventLoop eventLoop) { > while ((cast() eventLoop).loop()) { > continue; The p

Re: Starting and managing threads

2022-01-15 Thread Bagomot via Digitalmars-d-learn
On Saturday, 15 January 2022 at 19:07:20 UTC, frame wrote: On Wednesday, 12 January 2022 at 08:50:09 UTC, Bagomot wrote: Why? What am I doing wrong? I guess your main() exits and just ends all threads? No, the program continues to run. And I tested it with while in main.

Re: Starting and managing threads

2022-01-15 Thread frame via Digitalmars-d-learn
On Wednesday, 12 January 2022 at 08:50:09 UTC, Bagomot wrote: Why? What am I doing wrong? I guess your main() exits and just ends all threads?

Re: Starting and managing threads

2022-01-15 Thread Bagomot via Digitalmars-d-learn
On Wednesday, 12 January 2022 at 08:50:09 UTC, Bagomot wrote: Good day! I keep giving rise to problems. Above, Tejas helped me a lot, but still doesn't work. I gave up using the fswatch library, thinking that the problem was in it. Now trying to do it using libasync. Here is the code that runs

Re: Starting and managing threads

2022-01-12 Thread Bagomot via Digitalmars-d-learn
Good day! I keep giving rise to problems. Above, Tejas helped me a lot, but still doesn't work. I gave up using the fswatch library, thinking that the problem was in it. Now trying to do it using libasync. Here is the code that runs on the main thread, it blocks further actions on that thread.

Re: Starting and managing threads

2021-12-28 Thread Bagomot via Digitalmars-d-learn
Thanks! It works. Perhaps there will still be difficulties, I will write here.

Re: Starting and managing threads

2021-12-28 Thread Tejas via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 16:29:05 UTC, Bagomot wrote: I can't do it according to your example, my Watcher list fills up at runtime. Yes, it's possible to do it at runtime as well(it already _was_ happening at runtime), although I'll be using a `cast` for convenience now. ```d import

Re: Starting and managing threads

2021-12-28 Thread Bagomot via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 15:42:04 UTC, Tejas wrote: On Tuesday, 28 December 2021 at 14:19:46 UTC, Bagomot wrote: On Monday, 27 December 2021 at 10:59:07 UTC, Ali Çehreli wrote: On 12/27/21 1:33 AM, Bagomot wrote: > separate thread, without blocking the main one. I think you can use std

Re: Starting and managing threads

2021-12-28 Thread Tejas via Digitalmars-d-learn
On Tuesday, 28 December 2021 at 14:19:46 UTC, Bagomot wrote: On Monday, 27 December 2021 at 10:59:07 UTC, Ali Çehreli wrote: On 12/27/21 1:33 AM, Bagomot wrote: > separate thread, without blocking the main one. I think you can use std.concurrency there. I have a chapter here: http://ddili

Re: Starting and managing threads

2021-12-28 Thread Bagomot via Digitalmars-d-learn
On Monday, 27 December 2021 at 10:59:07 UTC, Ali Çehreli wrote: On 12/27/21 1:33 AM, Bagomot wrote: > separate thread, without blocking the main one. I think you can use std.concurrency there. I have a chapter here: http://ddili.org/ders/d.en/concurrency.html Look for 'struct Exit' to see

Re: Starting and managing threads

2021-12-27 Thread Ali Çehreli via Digitalmars-d-learn
On 12/27/21 1:33 AM, Bagomot wrote: > separate thread, without blocking the main one. I think you can use std.concurrency there. I have a chapter here: http://ddili.org/ders/d.en/concurrency.html Look for 'struct Exit' to see how the main thread signals workers to stop running. And some s

Starting and managing threads

2021-12-27 Thread Bagomot via Digitalmars-d-learn
Hello everybody! My program uses the fswatch library to track changes in a directory. It runs on the main thread of the program. I need it to do its work in a separate thread, without blocking the main one. In addition, I need to be able to terminate the thread at the moment I want from the m