Ice 多线程模式

A thread pool is a collection of threads that the Ice run time draws upon to
perform specific tasks. Each communicator creates two thread pools:
• The client thread pool services outgoing connections, which primarily
involves handling the replies to outgoing requests and includes notifying AMI
callback objects. If a connection is used in bidirectional mode (see
Section 36.7), the client thread pool also dispatches incoming callback
requests.
• The server thread pool services incoming connections. It dispatches incoming
requests and, for bidirectional connections, processes replies to outgoing
requests.
By default, these two thread pools are shared by all of the communicator’s object
adapters. If necessary, you can configure individual object adapters to use a
private thread pool instead.
If a thread pool is exhausted because all threads are currently dispatching a
request, additional incoming requests are transparently delayed until a request
completes and relinquishes its thread; that thread is then used to dispatch the next
pending request. Ice minimizes thread context switches in a thread pool by using a
leader-follower implementation

 

1. 多线程池:应付多个 客户端的请求rpc调用。只有客户端调用代理操作才占用一个处理线程。这就要求rpc 调用是线程安全的

 

2. Single-Threaded Pool 的优势:

  There are several implications of using a thread pool with a maximum size of one
thread:
• Only one message can be dispatched at a time.
This can be convenient because it lets you avoid (or postpone) dealing with
thread-safety issues in your application (see Section 32.10.6). However, it also
eliminates the possibility of dispatching requests concurrently, which can be a
bottleneck for applications running on multi-CPU systems or that perform
blocking operations. Another option is to enable serialization in a multithreaded
pool, as discussed on page 1006.
• Only one AMI reply can be processed at a time.
An application must increase the size of the client thread pool in order to
process multiple AMI callbacks in parallel.
• Nested twoway invocations are limited.
At most one level of nested twoway invocations is possible.

你可能感兴趣的:(Ice 多线程模式)