-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Concurrency issues #4
Comments
Hi, Thanks for taking such a close look at the code. 2013/9/21 Peter Vahlstrup [email protected]
Switching to a ConcurrentHashMap would prevent the possibility of seeing an We should update the class documentation to clarify the intended use of the
We should document make the intended use of the class clear in the class
This is indeed a bug. Nice catch! Sekhar C. Ramakrishnan [email protected] |
Happy to help :)
Agreed, sorry for vague formulation
Even though it shouldn't be mutated in another thread there will (could) still be visibility issues if the setters and getters are not synchronized or the fields are not final. That is if the object crossed thread boundaries (on multi-core processors). the Java Memory Model describes this: http://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.5-110 |
This should make this thread-safe as long as startListening() and stopListening() are only called from a single thread. Takes care of part of issue hoijui#4
I think there is one more threading problem. When you send data one OSCSerializer is built per sending operation, as it is not thread safe, but they all share the buffer from the OSCPortOut. |
I'm consistently getting an error when receiving values quickly. I figure it's not hard to avoid, I really don't need to receive the instructions that quickly but thought it related to this thread. If you need any more info I can provide to help fix this let me know, it's quite easy to reproduce.
|
Hi there, nice little API :-)
It has some concurrency issues though which needs attention, I will be happy to give some pointers if the project is still active. E.g.
OSCPacketDispatcher:
You need to use a ConcurrentHashMap for this to be thread safe, if you where to add a listener after OSCPortIn has started receiving messages there could be visibility issues of the newly added listener and ConcurrentModificationExceptions could occur
OSCMessage:
is not Immutable and therefore not thread safe. This can cause issues with visibility when crossing thread boundaries
OSCPortIn:
The listening flag will be accessed by multiple threads and is not currently thread safe. Should be changed to volatile or accessed In thread safe manner. If not this could cause visibility issues and in worst case it will never stop running because it want see the state change of the listening flag.
.... More issues....
The text was updated successfully, but these errors were encountered: