digitalmars.D - send doesn't work
- unDEFER (23/23) Nov 15 2016 Hello!
- Daniel Kozak via Digitalmars-d (8/30) Nov 15 2016 Yous should post this into Learn news group not in General. And it would...
- unDEFER (4/11) Nov 15 2016 If the problem will appears again I will try to make short not
- Steven Schveighoffer (3/25) Nov 15 2016 Without more complete code, it's difficult to say what is happening.
- unDEFER (4/7) Nov 15 2016 Code is big. I of course can return to the question when the code
- unDEFER (4/4) Nov 15 2016 Now I'm sending "hello"-message from child thread in the loop
- Steven Schveighoffer (9/12) Nov 15 2016 1. I'm sure it's not "magic" but likely something you are missing.
- unDEFER (9/18) Nov 15 2016 So, the problem still here. Sometimes it is working with
- Steven Schveighoffer (7/23) Nov 15 2016 From experience, this smells like a race condition. I'd try removing
- unDEFER (3/3) Nov 16 2016 Really situation is much more interesting:
- unDEFER (9/10) Nov 16 2016 And I have found the error! And you are right! It is really race
- Steven Schveighoffer (3/10) Nov 16 2016 Glad you figured it out!
- Era Scarecrow (6/10) Nov 16 2016 I just have to wonder every time I look at this... how long is 1
- unDEFER (4/9) Nov 16 2016 Really I have wanted to write 0ms, but don't sure that it is
- Anonymouse (4/14) Nov 16 2016 receiveTimeout(0.seconds,
- unDEFER (2/5) Nov 17 2016 Thanks!
- Is it possible to store different generic types? (2/8) Nov 18 2016 You can also do -1 for instant receive.
Hello! In my thread I'm sending the Tid of the thread to the parent to inform it about finishing: send(tid, thisTid); The parent thread has the next code to receive it and handle: receiveTimeout( dur!"hnsecs"(1), (Tid tid) {//the message from child thread handler} ); It is good works for my first child thread. But, some times ago I have added the second child thread (no, no, the first thread and the second thread works not simultaneously) and have found that the receiving message doesn't work! The parent doesn't get the message although the child sends it. So in my code have appeared the next insertion in the start of thread: /* Strange, but without sending message at start thread makes not working sending at end thread */ send(tid, "Hello"); Now I have added the third child thread. At the first it have worked good, but now it again doesn't receive the message. And "send hello"-hack doesn't help. What to do? Why the sending of the message may doesn't work?
Nov 15 2016
Dne 15.11.2016 v 17:36 unDEFER via Digitalmars-d napsal(a):Hello! In my thread I'm sending the Tid of the thread to the parent to inform it about finishing: send(tid, thisTid); The parent thread has the next code to receive it and handle: receiveTimeout( dur!"hnsecs"(1), (Tid tid) {//the message from child thread handler} ); It is good works for my first child thread. But, some times ago I have added the second child thread (no, no, the first thread and the second thread works not simultaneously) and have found that the receiving message doesn't work! The parent doesn't get the message although the child sends it. So in my code have appeared the next insertion in the start of thread: /* Strange, but without sending message at start thread makes not working sending at end thread */ send(tid, "Hello"); Now I have added the third child thread. At the first it have worked good, but now it again doesn't receive the message. And "send hello"-hack doesn't help. What to do? Why the sending of the message may doesn't work?Yous should post this into Learn news group not in General. And it would be better if you provided full (not)working example. and I guess you have this receiveTimeout( dur!"hnsecs"(1), (Tid tid) {//the message from child thread handler} ); in some while(true) loop?
Nov 15 2016
On Tuesday, 15 November 2016 at 18:11:38 UTC, Daniel Kozak wrote:Yous should post this into Learn news group not in General. And it would be better if you provided full (not)working example.If the problem will appears again I will try to make short not working example..and I guess you have this receiveTimeout( dur!"hnsecs"(1), (Tid tid) {//the message from child thread handler} ); in some while(true) loop?Of course there is while(!gs.finish) :-)
Nov 15 2016
On 11/15/16 11:36 AM, unDEFER wrote:Hello! In my thread I'm sending the Tid of the thread to the parent to inform it about finishing: send(tid, thisTid); The parent thread has the next code to receive it and handle: receiveTimeout( dur!"hnsecs"(1), (Tid tid) {//the message from child thread handler} ); It is good works for my first child thread. But, some times ago I have added the second child thread (no, no, the first thread and the second thread works not simultaneously) and have found that the receiving message doesn't work! The parent doesn't get the message although the child sends it. So in my code have appeared the next insertion in the start of thread: /* Strange, but without sending message at start thread makes not working sending at end thread */ send(tid, "Hello"); Now I have added the third child thread. At the first it have worked good, but now it again doesn't receive the message. And "send hello"-hack doesn't help. What to do? Why the sending of the message may doesn't work?Without more complete code, it's difficult to say what is happening. -Steve
Nov 15 2016
On Tuesday, 15 November 2016 at 18:12:32 UTC, Steven Schveighoffer wrote:Without more complete code, it's difficult to say what is happening. -SteveCode is big. I of course can return to the question when the code will available on the git. But now it is not available.
Nov 15 2016
Now I'm sending "hello"-message from child thread in the loop every iteration, and the last message again working. What the magic??? The send-subsystem "becomes rotten" if don't use it???
Nov 15 2016
On 11/15/16 1:13 PM, unDEFER wrote:Now I'm sending "hello"-message from child thread in the loop every iteration, and the last message again working. What the magic??? The send-subsystem "becomes rotten" if don't use it???1. I'm sure it's not "magic" but likely something you are missing. 2. Nobody here can help you without a working demonstration. i.e., this isn't a known issue, and others have used the concurrency subsystem without such problems. If you construct a small example that demonstrates the problem, that is helpful for diagnosis (or better yet, may demonstrate to you why it's not working in your full codebase). -Steve
Nov 15 2016
On Tuesday, 15 November 2016 at 18:23:16 UTC, Steven Schveighoffer wrote:1. I'm sure it's not "magic" but likely something you are missing. 2. Nobody here can help you without a working demonstration. i.e., this isn't a known issue, and others have used the concurrency subsystem without such problems. If you construct a small example that demonstrates the problem, that is helpful for diagnosis (or better yet, may demonstrate to you why it's not working in your full codebase). -SteveSo, the problem still here. Sometimes it is working with hello-messages, but sometimes doesn't work. I will try to make minimal application. But I don't know still what it must do. Trying to minimize the main thread to starter of the second thread shows that the problems goes away.. So it will really not easy, but I will try... Thank you.
Nov 15 2016
On 11/15/16 1:56 PM, unDEFER wrote:On Tuesday, 15 November 2016 at 18:23:16 UTC, Steven Schveighoffer wrote:From experience, this smells like a race condition. I'd try removing features of your program until it starts working, then you may have your answer. I'd suggest dustmite may help, but in the case of non-deterministic failure, it's more difficult to have it work. -Steve1. I'm sure it's not "magic" but likely something you are missing. 2. Nobody here can help you without a working demonstration. i.e., this isn't a known issue, and others have used the concurrency subsystem without such problems. If you construct a small example that demonstrates the problem, that is helpful for diagnosis (or better yet, may demonstrate to you why it's not working in your full codebase).So, the problem still here. Sometimes it is working with hello-messages, but sometimes doesn't work. I will try to make minimal application. But I don't know still what it must do. Trying to minimize the main thread to starter of the second thread shows that the problems goes away.. So it will really not easy, but I will try... Thank you.
Nov 15 2016
Really situation is much more interesting: Sometimes I got Tid not the same as sent. Sometimes I receive 2 TID although sent only 1.
Nov 16 2016
On Tuesday, 15 November 2016 at 20:46:59 UTC, Steven Schveighoffer wrote:From experience, this smells like a race condition.And I have found the error! And you are right! It is really race condition. The problem was that I had not one receiveTimeout() but 3 receiveTimeout() for each thread. I don't know how I expect that each send must go to his own receiveTimeout, but of course it was false. Big thanks to all!
Nov 16 2016
On 11/16/16 4:35 AM, unDEFER wrote:On Tuesday, 15 November 2016 at 20:46:59 UTC, Steven Schveighoffer wrote:Glad you figured it out! -SteveFrom experience, this smells like a race condition.And I have found the error! And you are right! It is really race condition. The problem was that I had not one receiveTimeout() but 3 receiveTimeout() for each thread. I don't know how I expect that each send must go to his own receiveTimeout, but of course it was false. Big thanks to all!
Nov 16 2016
On Tuesday, 15 November 2016 at 16:36:00 UTC, unDEFER wrote:The parent thread has the next code to receive it and handle: receiveTimeout( dur!"hnsecs"(1), (Tid tid) {//the message from child thread handler} );I just have to wonder every time I look at this... how long is 1 hnsecs? I'd assume not very long. Either blocking unless there's no more messages, or having a longer timeout period seems a better bet. Might make it 1-5ms.
Nov 16 2016
On Wednesday, 16 November 2016 at 10:54:32 UTC, Era Scarecrow wrote:I just have to wonder every time I look at this... how long is 1 hnsecs? I'd assume not very long. Either blocking unless there's no more messages, or having a longer timeout period seems a better bet. Might make it 1-5ms.Really I have wanted to write 0ms, but don't sure that it is possible.
Nov 16 2016
On Wednesday, 16 November 2016 at 13:10:06 UTC, unDEFER wrote:On Wednesday, 16 November 2016 at 10:54:32 UTC, Era Scarecrow wrote:receiveTimeout(0.seconds, /* ... */ );I just have to wonder every time I look at this... how long is 1 hnsecs? I'd assume not very long. Either blocking unless there's no more messages, or having a longer timeout period seems a better bet. Might make it 1-5ms.Really I have wanted to write 0ms, but don't sure that it is possible.
Nov 16 2016
On Wednesday, 16 November 2016 at 20:20:07 UTC, Anonymouse wrote:receiveTimeout(0.seconds, /* ... */ );Thanks!
Nov 17 2016
On Thursday, 17 November 2016 at 11:37:37 UTC, unDEFER wrote:On Wednesday, 16 November 2016 at 20:20:07 UTC, Anonymouse wrote:You can also do -1 for instant receive.receiveTimeout(0.seconds, /* ... */ );Thanks!
Nov 18 2016