Fibers concurrency doubts

121 views
Skip to first unread message

Cristian Lorenzetto

unread,
Dec 10, 2017, 7:00:38 AM12/10/17
to quasar-pulsar-user
Hi i d like add fibers in my project but i have some  doubs not really clear in documentation.



1) supposing i m using a consumer-producer queue in which  the producer is a thread and consumer is a fiber.I supposed i have replaced all synchronized blocks with Mutex lock (using quasar lib) and using Strand park. 
I dont know really how works Concurrency in quasar but I m supposing Strand can understand automalically if the running context is a thread or a fiber using a ThreadLocal setting a status like fiber=true/false.
So park and locks can have the right behaviour if i m in a Thread or in a fiber. It is so? Can I use indipendently thread or fibers if i use Strand park and pulsar Mutex?
Anyway it is not clear why quasar using instrumentation can not replace old synchonized blocks with quasar mutexes or maybe already does it exist?



2) Considering i have a old legacy library where inside you can find synchonized/wait/notify or default muxex object or jni code.
    You can consider this library a black box in which you have just thread-safe apis like  
        Object func(arg1,...) 
    Is there a way for calling these apis inside a Fiber? 
    Readiing documentations it seams:
   2a)FiberAsync: seams developped for converting async operation in a blocking operation. In my case it is opposite. 
   2b) Channels:  it is not clear if channels is designed for working also in legacy code. 
         Maybe it is possible to pass the legacy result to channel using a default Thread and receive a object inside a Fiber/actor. This scenario is really scalable? is there a high overhead comparing to not use this             work around?
        


Reply all
Reply to author
Forward
0 new messages