Archived

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

Using ICE with OpenSceneGraph

I'm looking for hints or suggestions on using threads correctly when ICE is used with another library that is also threaded. I was thinking about using the Command Processor design pattern and collect command objects into a thread safe queue and then dispatch these objects during a "safe time".

Comments

  • bernard
    bernard Jupiter, FL
    Hi Joseph,

    Ice is fully thread-safe, so I don't understand your question. Could you describe the problem you want to avoid?

    Best regards,
    Bernard
  • Two questions: OpenSceneGraph (OSG) has a main loop that handles processing events and its threads and I'd assume that ICE has something simular that also handles its events and threads. It's straight forward to decompose OSG's main loop and place it inside another loop that is in the main process. Where do I need to look in ICE's documentation/code on how to do this? Secondly, the OSG code needs to run a fairly constant rate. Does the main loop in ICE ever block?

    Thanks
  • marc
    marc Florida
    Ice does not have a main loop. You can use the main thread for whatever you like. Requests are dispatched in separate threads from a thread pool.
  • bernard
    bernard Jupiter, FL
    Ice does not have a main loop -- it's not a wrapper on top of a single-threaded library.

    Assuming you use Ice and OpenSceneGraph in a server, each Ice request will be dispatched using a thread from the Ice server thread pool; if the request needs to interact with OpenSceneGraph, it will most likely need to enqueue a work-item and wait for OSG's thread to pick up this work-item.

    In an Ice client, sending Ice requests from the OSG thread is possible, but can block for various reasons:
    - the server is slow to respond (solution: use AMI)
    - establishing the connection to the server takes a long time (e.g. because the server is out of thread)
    - the client TCP buffer is full (typically because the server is overloaded or deadlocked)
    It would be safer, although more complicated, to use a separate thread to send these requests.

    Cheers,
    Bernard