Migrating legacy code - how to replace wait/notify?

107 views
Skip to first unread message

Anton Vodonosov

unread,
Aug 19, 2017, 12:44:47 AM8/19/17
to quasar-pulsar-user
Hello,

I have legacy code where threads wait for data using java.lang.Object.wait();

I'm want to implement asynchronous handling. But avoid manual, error-prone migration I consider using automatic continuation-passing style transformation like Quasar does.

However, calling native synchronized and wait() will block Quasar schedule. So I need some equivalent API to replace the waits.

Are the suitable classes to replace native java synchronization primitives with exactly the same API so that I just replace wait() notify with new calls of the replacement classes and don't need to refactor the surrounding code?

Best regards,
- Anton

Anton Vodonosov

unread,
Aug 19, 2017, 12:51:18 AM8/19/17
to quasar-pulsar-user
Note, the legacy code uses wait() with a timeout. The legacy method needs to wait for data for 30 seconds. As Object.wait() can have spurious wakeups, the waiting is done in a loop. Another reason for the loop is that the data supplied by the other side of the queue is filtered in this method so that waiting may need to continue even if the wake-up wasn't spurious.

Best regards,
- Anton

Anton Vodonosov

unread,
Aug 19, 2017, 1:25:36 AM8/19/17
to quasar-pulsar-user
Note, I want to convert only the "consumer" side of the queue. The producer will remain non-Quasar.

Cristian Lorenzetto

unread,
Dec 10, 2017, 7:11:25 AM12/10/17
to quasar-pulsar-user
I m not a expert in quasar but i have similar problems

if you can replace code, you might using quasar mutex (in concurrent lib). For wait/notify using Strand.park. I didnt receive any answers to this questions so i m reasoning with logic for deducting ....
If you use Quasar mutex/park just in one side ... i think it dont work because producer and consumer will use different locks. 
In my case a problem more complex. I cant replace the code in old lib. 
I was thinking to use channels for passing the result from a default context to fiber context. 
I m not sure if it has a sense.... in performance. 
Anyway i think quasar might be developed inside JVM for evoiding all this problems. 
Reply all
Reply to author
Forward
0 new messages