retrofit
retrofit copied to clipboard
Replace use of synchronized in OkHttpCall with ReentrantLock
We use Retrofit in our backend, and I notice that retrofit2.OkHttpCall relies extensively on synchronized(this), which can pin host threads (when using virtual threads). Would you be open to a PR replacing use of synchronized here with use of ReentrantLock?
It might be better to replace it with a compare and swap loop with an atomic? We're not guarding an operation, just performing creation where only a single instance can win. Plus the idea of contention here is near zero, and the cost of double allocation before a winner is determined is negligible.
Thanks for the pointer - I'll take a look!