Sorry, I run your example and it's immediately failing with this message:
    
    
    D:\test.nim(203) receiver
    Error: unhandled exception: Message received is invalid:
    myMsg.str (This is a test for: 19) != "This is a test for: 27" [ValueError]
    D:\test.nim(203) receiver
    Error: unhandled exception: Message received is invalid:
    myMsg.str (This is a test for: 29) != "This is a test for: 33" [ValueError]
    
    
    Run

So I thought this is the usual case of race-condition, the changes could be
    
    
    withLock channel.lock:
      (channels.list[uniqueStr],
      senderThreads[uniqueStr]) =
            addSenderThreadWithChannel(uniqueStr)
    
    withLock channel.lock
          receiverThreads[uniqueStr] =
            addReceiverThreadWithChannel(
              uniqueStr,
              channels.list[uniqueStr])
    
    
    Run

but apparently it yielded the same. There should anywhere which make it 
race-condition but other than `channel.list` but I couldn't see it in others. 
Also running it simply with `nim r --threads:on test.nim` so maybe it could be 
different with `-d:release` .

Reply via email to