Active Object 并发模式在 Java 中的应用
2010-08-06 00:00:00 来源:WEB开发网实现 Proxy,如清单 2 所示:
清单 2. MQ_Proxy
class MQ_Proxy {
public:
// Bound the message queue size.
enum { MQ_MAX_SIZE = 100 };
MQ_Proxy (size_t size = MQ_MAX_SIZE)
:scheduler_ (size),
servant_ (size) {
}
// Schedule <put> to execute on the active object.
void put (const Message &msg) {
Method_Request *mr = new Put(servant_,msg);
scheduler_.insert (mr);
}
// Return a <Message_Future> as the "future" result of
// an asynchronous <get> method on the active object.
Message_Future get () {
Message_Future result;
Method_Request *mr = new Get (&servant_,result);
scheduler_.insert (mr);
return result;
}
// empty() and full() predicate implementations ...
private:
// The servant that implements the active object
// methods and a scheduler for the message queue.
MQ_Servant servant_;
MQ_Scheduler scheduler_;
};
同一个进程中的多个调用者线程可以共享同一个 Proxy。
实现 Method Request,如清单 3 所示:
清单 3. Method_Request
- ››Active Directory的复制拓扑,Active Directory系...
- ››Active Directory的主要还原,Active Directory系...
- ››Active Directory的脱机碎片整理,Active Directo...
- ››Objective-c 学习: 初始化
- ››Objective C内存管理进阶: 调试内存泄露
- ››Active Object 并发模式在 Java 中的应用
- ››ActiveFile 手机文件管理
- ››Active Directory网络中DNS服务器的规划
- ››ActiveSkin 4.3软件换肤在VC中的实现
- ››Active Memory Sharing 与双 Virtual I/O Server ...
- ››ActiveX 控件在 Excel 中的运用
- ››Active Diretory 全攻略(三)--建立域(4)
更多精彩
赞助商链接