saltyrtc / saltyrtc-client-java

SaltyRTC Java implementation.
Apache License 2.0
3 stars 4 forks source link

Fix synchronisation #114

Open lgrahl opened 5 years ago

lgrahl commented 5 years ago

This library is not thread-safe and thus does not need synchronisation. All synchronized blocks and synchronised lists etc. should be removed/replaced.

Since the WebSocket implementation does use threads internally, we still need synchronisation between it and the public API surface. I see a couple of options:

  1. Make everything synchronized.
  2. Introduce an API to hand in a lock from the application that is being used for pretty much everything.
  3. Get rid of the WebSocket threads and allow this library to be run single-threaded (my preference, mid-term).
  4. Remove the WebSocket transport. Create a transport interface and let the application create its own WebSocket transport (my preference, long-term).
dbrgn commented 5 years ago

I'd explore 3, potentially using a single thread executor service: https://github.com/TakahikoKawasaki/nv-websocket-client#connect-to-server-asynchronously

ovalseven8 commented 5 years ago

I'm not entirely sure what you mean, @dbrgn. Can you explain how you would structure that?

ovalseven8 commented 5 years ago

For the time being #125 basically introduces @lgrahl's 1./2.