AsynchronousUpdates: Difference between revisions
No edit summary |
No edit summary |
||
Line 89: | Line 89: | ||
{ | { | ||
public: | public: | ||
void ProcessEvents(); | |||
}; | }; | ||
* | * The implementation of vtkSMEventDispatcher::ProcessEvents() handles pending I/O for all connected servers, emitting asynchronous events as-needed. | ||
* Add a vtkSMApplication::GetEventDispatcher() method that returns a reference to | * Add a vtkSMApplication::GetEventDispatcher() method that returns a reference to vtkSMEventDispatcher. | ||
* Clients register with the vtkSMEventDispatcher object returned by vtkSMApplication::GetEventDispatcher() to receive events. | * Clients register with the vtkSMEventDispatcher object returned by vtkSMApplication::GetEventDispatcher() to receive events. |
Revision as of 15:53, 5 December 2005
Requirements
- When multiple clients are connected to a server, ensure that server state changes are propagated to all clients so they remain in-sync.
- Ensure that user interfaces remain responsive at all times.
- Avoid multithreading, see ThreadedGUI.
Use Cases
- Two-or-more clients are connected to a server. Client "A" makes a change to the server state. Client "B", et al, are notified of the change.
- A client with a graphical user interface is connected to a server. The client initiates a time-consuming recalculation of the visualization network. The call to the server should return immediately, and the client should be notified asynchronously as calculation progresses and when the calculations are complete.
Design
VTK already provides a straightforward implementation of Observer Design Pattern, using derivatives of the vtkCommand class, plus methods of vtkObject. The ParaView Server Manager can easily expose an object derived from vtkObject that will allow clients to register observers for s1erver events.
To maintain the responsiveness of graphical user interfaces on the client, the client's event loop must be allowed to run continuously. At the same time, the server manager must also be allowed to run frequently, so that it can handle I/O with connected servers and emit asyncronous events. To accomplish this, the server manager will expose an API function that is called periodically by the client. This function can be called in an idle handler or by a timer, allowing the UI to remain responsive to user input. This assumes that the server manager is coded so that commands issued by the client return immediately.
Implementation
- The set of events enumerated in vtkCommand::EventIds will have to be expanded to include events appropriate to the server manager:
Event | Description | Arguments |
---|---|---|
ServerConnected | emitted when a connection to a server is made, see Secure_Connections | pqServer*? Implies that pqServer moves into PVS |
ServerDisconnected | emitted when a connection to a server ends | pqServer*? Implies that pqServer moves into PVS |
UndoStackAdded | emitted when a client creates a new undo stack | vtkSMUndoStack*? |
UndoStackDeleted | emitted when a client deletes an undo stack | vtkSMUndoStack*? |
ProxyAdded | emitted when a proxy is created | vtkSMProxy* |
ProxyDeleted | emitted when a proxy is deleted | vtkSMProxy* |
PropertyAdded | emitted when a property is added to a proxy | vtkSMProperty* |
PropertyDeleted | emitted when a property is removed from a proxy | vtkSMProperty* |
PropertyLinked | emitted when two properties are linked | vtkSMProperty*, vtkSMProperty* |
PropertyUnlinked | emitted when two properties are unlinked | vtkSMProperty*, vtkSMProperty* |
PropertyValueChanged | emitted when a property value changes | vtkSMProperty* |
PropertyDomainChanged | emitted when a property domain changes (or the domain properties change) | vtkSMDomain* |
RenderStarted | emitted when rendering begins | pqServer*? |
RenderProgress | emitted periodically during rendering to indicate progress | pqServer*? |
RenderComplete | emitted when rendering ends | pqServer*? |
- Create a new class to manage asynchronous events (simplified for clarity):
class vtkSMEventDispatcher : public vtkObject { public: void ProcessEvents(); };
- The implementation of vtkSMEventDispatcher::ProcessEvents() handles pending I/O for all connected servers, emitting asynchronous events as-needed.
- Add a vtkSMApplication::GetEventDispatcher() method that returns a reference to vtkSMEventDispatcher.
- Clients register with the vtkSMEventDispatcher object returned by vtkSMApplication::GetEventDispatcher() to receive events.
- Clients call vtkSMApplication::GetEventDispatcher().ProcessEvents() periodically to give the server manager a chance to handle I/O and emit events.
- (Alternative) If it is determined that a multi-threaded server-manager design is required, clients still register to receive events from the object returned by vtkSMApplication::GetEventDispatcher(), but no longer have to call ProcessEvents().