Active Object 并发模式在 Java 中的应用
2010-08-06 00:00:00 来源:WEB开发网class Method_Request {
public:
// Evaluate the synchronization constraint.
virtual bool can_run () const = 0
// Execute the method.
virtual void call () = 0;
};
// Inherites from Method_Request
class Get : public Method_Request {
public:
Get (MQ_Servant *rep, const Message_Future &f)
:servant_ (rep),
result_ (f)
{
}
virtual bool can_run () const {
// Synchronization constraint: cannot call a
// <get> method until queue is not empty.
return !servant_->empty ();
}
virtual void call () {
// Bind dequeued message to the future result.
result_ = servant_->get ();
}
private:
MQ_Servant *servant_;
Message_Future result_;
};
实现 Activation List,如清单 4 所示:
清单 4. Activation_List
class Activation_List {
public:
// Block for an "infinite" amount of time waiting
// for <insert> and <remove> methods to complete.
enum { INFINITE = -1 };
// Define a "trait".
typedef Activation_List_Iterator iterator;
Activation_List ();
// Insert <method_request> into the list, waiting up
// to <timeout> amount of time for space to become
// available in the queue. Throws the <System_Ex>
// exception if <timeout> expires.
void insert (Method_Request *method_request,Time_Value *timeout = 0);
// Remove <method_request> from the list, waiting up
// to <timeout> amount of time for a <method_request>
// to be inserted into the list. Throws the
// <System_Ex> exception if <timeout> expires.
void remove (Method_Request *&method_request, Time_Value *timeout = 0);
private:
// Synchronization mechanisms, e.g., condition
// variables and mutexes, and the queue implementation,
// e.g., an array or a linked list, go here.
};
- ››Object转换为String[]数组,或者其他类型的数组
- ››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 中的运用
更多精彩
赞助商链接