Threading / Concurrency Problem

Meta jared771 at gmail.com
Wed Oct 23 05:20:30 PDT 2013


On Wednesday, 23 October 2013 at 11:51:35 UTC, Bauss wrote:
> Working on a 2nd simple webserver in D. However I am facing a 
> problem with some threading. I want the receiving of 
> connections to happen in a 2nd thread, but after adding the 
> connections to the collection it seems like the receive thread 
> never loops through them, as if no connections were ever added. 
> However I have checked and it is added.
>
> The thread for receiving is also working as I have checked if 
> code outside of the foreach loop works and it does, so it's 
> probably a problem with the collection.
>
> This makes me assume it's a concurrency issue and I'm not sure 
> how to fix it.
>
> I'm using an associative array for the connections. Class[int] 
> is the format I'm using.
>
> You can view my code here:
>
> If anyone knows the solution to this, it would be appreciated. 
> I can't seem to figure it out.
>
> Code:
> http://pastebin.com/A61NPWUq

Possibly try marking Connections as shared. I can't compile your 
example because it's missing import statements.


More information about the Digitalmars-d-learn mailing list