Archived

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

Bidirectional callbacks and mutexes

Dear ZeroC staff,
I have a question regarding the example that show the use of bidirectional connections for callbacks.

Why do you use the mutex? What does it protect?
Does this mutex protect the queue of clients that asks for this service or just the working thread?

In this demo, is the server able to serve multiple clients at the same time?


Thanks a lot

With my very best regards


Alberto

Comments

  • mes
    mes California
    Hi,
    albertods wrote:
    Does this mutex protect the queue of clients that asks for this service or just the working thread?
    The mutex is used simply to protect the client list.
    In this demo, is the server able to serve multiple clients at the same time?
    Yes, it can handle multiple clients. The way it's written, however, a call to addClient would block until the callback thread finishes its invocations.

    Normally we recommend that you avoid holding locks while making remote invocations because of the risk of blocking and deadlocks (see Bernard's two-part series of newsletter articles starting in issue 4 for more information).

    Hope that helps,
    - Mark