hiddenswitch / Meteor-Unity

A Unity SDK for Meteor.
MIT License
94 stars 23 forks source link

Possible multithread bug in message queue #17

Open green-coder opened 8 years ago

green-coder commented 8 years ago

This queue is used by multiple threads but I am afraid that the Queue class it is not thread safe.

doctorpangloss commented 8 years ago

I'll investigate to what extent this is an issue. Unity is single threaded and this is their code borrowed from their websocket wrapper around web-socket-sharp. Broadly speaking, it should be possible to just use lock around accesses to the queue but I don't know if that's necessary...

green-coder commented 8 years ago

I do think that there are multiple threads, but I don't know if your use of the Queue class will be problematic or not.

FYR, I implemented a DDP-client for Unity3D recently, and I used this class for the queue. Maybe that class can help you.

doctorpangloss commented 7 years ago

I know this is a stale issue, but I believe today, there is an issue with using the regular queue class with the current websocketsharp lib. I have been using the exact ConcurrentQueue implementation from 4.0.0.0 mscorlib (Microsoft's code) and I'll port it into the package here soon.