Passive objects are normally put there and will not be moved, waiting for other execution threads to call and then will be executed. Active objects generally contain execution threads and can actively execute code.
1. The active object is based on the ace_task class and provides the execution thread.
2. When some code to be executed is to be executed, it should be put into a queue. Then, when the execution thread finds that the queue is not empty, it will retrieve the objects in the queue from the queue and then execute it. This queue is ace_activation_queue.
3. objects placed in ace_activation_queue are called method objects. These objects inherit from ace_method_object. ace_method_object provides a virtual function named "call" (which has only three functions, the other two are a constructor and a constructor), which implements the call function of the method object and can be called in the SVC function of the active object (inherited from the ace_task class.
4. to obtain the result of an asynchronous operation, you also need the ace_future object. After the asynchronous execution is complete, the execution thread sets this object. If you want to obtain the result before setting, it will be blocked until it is set.
Therefore, the process is as follows:
(1) create an active object and call its open function (activate is called in open, and SVC is called ).
(2) Call the dequeue () function of ace_activation_queue cyclically in the active object. If there is no method object in ace_activation_queue, it will be blocked.
(3) If a method object exists in ace_activation_queue at a time, the function will be successfully executed and passed, and it will return the pointer to the method object, then you can call the call function of this method object.
In this way, the method object will be successfully executed.
When an active object is used, it is put into ace_activation_queue after initialization of a method object, and other things are completed by the above steps.