Archived

This forum has been archived. Please start a new discussion on GitHub.

ServantLocator and dispatching thread

Is there any guarantee that the thread that calls locate on a
ServantLocator is the same that invokes the operation on the target
servant and then finished on the ServantLocator again ?

Regards,
Guido.

Comments

  • Re: ServantLocator and dispatching thread
    Originally posted by ganzuoni
    Is there any guarantee that the thread that calls locate on a
    ServantLocator is the same that invokes the operation on the target
    servant and then finished on the ServantLocator again ?

    Yes, that is guaranteed. You can, for example, safely acquire a lock in locate() and release it again in finished().

    Cheers,

    Michi.
  • marc
    marc Florida
    Re: Re: ServantLocator and dispatching thread
    Originally posted by michi
    Yes, that is guaranteed. You can, for example, safely acquire a lock in locate() and release it again in finished().

    Cheers,

    Michi.

    Except if you use AMD: Then the thread that finishes the request will also call finished().
  • Re: Re: Re: ServantLocator and dispatching thread
    Originally posted by marc
    Except if you use AMD: Then the thread that finishes the request will also call finished().

    In fact ! That's was my doubt.
    This means that if I need something identifying the "interaction" with
    a Servant (locate, invoke, finish) I must rely on the cookie ?
    If I understand well, there is also the chance for the thread that
    dispatched a request to manage another one before the previous
    gets completed, in the AMD scenario.

    Well, the origin of all it's always the problem of managing
    explicit Current vs ThreadLocalStorage approach.

    A hypotetical TransactionCurrent object should be designed around
    an InteractionLocalStorage concept rather than a ThreadLocal one.
    This kind of local storage can be setup on locate() and cleared on
    finished(), but works only with a ServantLocator.


    Regards,
    Guido.
  • Re: Re: Re: ServantLocator and dispatching thread
    Originally posted by marc
    Except if you use AMD: Then the thread that finishes the request will also call finished().

    Hi Marc,
    I have read chapter 15.6.3 and I am a bit confused.
    Can you clarify which threads are distinct in the following
    sequence of calls for an incoming request for both synch and
    async method dispatch:

    1. ServantLocator.locate
    2. xxx.operation
    3. ServantLocator.finish

    Reading the doc I am not sure if the thread that executes 1. and 2.
    is always the same, regardless the dispatch style, or not.

    Regards,
    Guido
  • marc
    marc Florida
    Re: Re: Re: Re: ServantLocator and dispatching thread
    Originally posted by ganzuoni
    Hi Marc,
    I have read chapter 15.6.3 and I am a bit confused.
    Can you clarify which threads are distinct in the following
    sequence of calls for an incoming request for both synch and
    async method dispatch:

    1. ServantLocator.locate
    2. xxx.operation
    3. ServantLocator.finish

    Reading the doc I am not sure if the thread that executes 1. and 2.
    is always the same, regardless the dispatch style, or not.

    Regards,
    Guido

    For regular synchronous dispatch (non-AMD), all of the above is done by the same thread (the dispatcher thread).

    For AMD, (1) and (2) are done by the dispatcher thread, and (3) is done by the thread that finishes the AMD requests (i.e. calls back on the provided AMD callback object).

    Cheers,
    Marc
  • Re: Re: Re: Re: Re: ServantLocator and dispatching thread
    Originally posted by marc
    For regular synchronous dispatch (non-AMD), all of the above is done by the same thread (the dispatcher thread).

    For AMD, (1) and (2) are done by the dispatcher thread, and (3) is done by the thread that finishes the AMD requests (i.e. calls back on the provided AMD callback object).

    Cheers,
    Marc

    You mean that in AMD scenario the dispatcher thread invokes
    ServantLocator.locate
    and
    xx.<operation>_async

    and another thread is activated by the invocation of
    response.ice_response(..) (or exception as well) issued from within
    xx.<operation>_async method body ??

    Regards,
    Guido.
  • Oops, please forgive and forget.
    Everything is clear on page 428.

    Really great doc upgrade !!

    Regards,
    Guido.
  • marc
    marc Florida
    Re: Re: Re: Re: Re: Re: ServantLocator and dispatching thread
    Originally posted by ganzuoni
    You mean that in AMD scenario the dispatcher thread invokes
    ServantLocator.locate
    and
    xx.<operation>_async

    and another thread is activated by the invocation of
    response.ice_response(..) (or exception as well) issued from within
    xx.<operation>_async method body ??

    Regards,
    Guido.

    No, in the AMD scenario, the dispatcher thread invokes locate() and the operation. Whichever thread calls ice_response() on the callback object will also invoke finished(). No thread is activated for that, the application has to provide the thread that calls back on the AMD callback object.