tailieunhanh - Symbian OS ExplainedEffective C++ Programming for Smartphones phần 5

TPckg và TPckgC lớp mẫu hữu ích cho các loại bao bì an toàn của các mô tả được xây dựng trong các loại đối tượng lớp T trong. Phương pháp này của "descriptorizing dữ liệu bằng phẳng là đặc biệt hữu ích cho đối tượng đi qua giữa máy khách và máy chủ, và được mô tả chi tiết trong Chương 10, 11 và 12. | ACTIVE OBJECT BASICS 129 object should handle the completed request. It uses its priority-ordered list of active objects inspecting each one in turn to determine whether it has a request outstanding. It does so by checking the iActive flag if the object does indeed have an outstanding request it then inspects its TRequestStatus member variable to see if it is set to a value other than KRequestPending. If so this indicates that the active object is associated with a request that has completed and that its event handler code should be called. Having found a suitable active object the active scheduler clears the active object s iActive flag and calls its RunL event handler. This method handles the event and may for example resubmit a request or generate an event on another object in the system. While this method is running other events may be generated but RunL is not pre-empted - it runs to completion before the active scheduler resumes control and determines whether any other requests have completed. Once the RunL call has finished the active scheduler re-enters the event processing wait loop by issuing another User WaitForAny-Request call. This checks the request semaphore and either suspends the thread if no other requests have completed in the meantime or returns immediately if the semaphore indicates that other events were generated while the previous event handler was running so the scheduler can repeat active object lookup and event handling. Here s some pseudo-code which represents the basic actions of the active scheduler s event processing loop. EventProcessingLoop Suspend the thread until an event occurs User WaitForAnyRequest Thread wakes when the request semaphore is signaled Inspect each active object added to the scheduler in order of decreasing priority Call the event handler of the first which is active completed FOREVER Get the next active object in the priority queue if activeObject- IsActive activeObject- iStatus KRequestPending Found an active .