Changeset 31116 in vbox
- Timestamp:
- Jul 26, 2010 2:34:03 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r31115 r31116 13971 13971 <desc> 13972 13972 Register an event listener. 13973 13973 13974 <note> 13974 For passive listeners, to avoid 13975 memory leaks and misbehavior of VirtualBox service, event source logic checks 13976 if event listener user performs checks for events with <link to="IEventSource::getEvent"/> frequently 13977 enough, so that event queue not overloaded. If heavy overuse (more that 100 13978 pending events with current implementation) of queue is detected, listener 13979 is forcefully unregistered and further getEvent() will return VBOX_E_OBJECT_NOT_FOUND. 13975 To avoid system overload, the VirtualBox server process checks if passive event 13976 listeners call <link to="IEventSource::getEvent"/> frequently enough. In the 13977 current implementation, if more than 100 pending events are detected for a passive 13978 event listener, it is forcefully unregistered by the system, and further 13979 <link to="#getEvent" /> calls will return @c VBOX_E_OBJECT_NOT_FOUND. 13980 13980 </note> 13981 13981 </desc> … … 13986 13986 <desc> 13987 13987 Event types listener is interested in. One can use wildcards like - 13988 <link to="VBoxEventType::Any"/> to specify wildcards, matching more 13988 <link to="VBoxEventType::Any"/> to specify wildcards, matching more 13989 13989 than one event. 13990 13990 </desc> … … 13998 13998 listeners. It is then up to the external code to call the listener's 13999 13999 <link to="IEventListener::handleEvent" /> method. When done with an event, the 14000 external code must call eventComplete().14000 external code must call <link to="#eventProcessed" />. 14001 14001 </desc> 14002 14002 </param> … … 14022 14022 <param name="timeout" type="long" dir="in"> 14023 14023 <desc> 14024 Timeout to wait until event processed in ms (if event is waitable),14025 0 - no wait, -1 - forever until delivered.14024 Maximum time to wait for event processing (if event is waitable), in ms; 14025 0 = no wait, -1 = indefinite wait. 14026 14026 </desc> 14027 14027 </param> … … 14033 14033 <method name="getEvent"> 14034 14034 <desc> 14035 Get events from this peer's event queue (for passive mode). 14036 <note> 14037 Please make sure you checked registerListener() documentation. 14038 </note> 14039 <see><link to="IEventSource::registerListener"/></see> 14035 Get events from this peer's event queue (for passive mode). Calling this method 14036 regularly is required for passive event listeners to avoid system overload; 14037 see <link to="IEventSource::registerListener" /> for details. 14038 14040 14039 <result name="VBOX_E_OBJECT_NOT_FOUND"> 14041 14040 Listener is not registered, or autounregistered. … … 14043 14042 </desc> 14044 14043 <param name="listener" type="IEventListener" dir="in"> 14045 <desc>Which listener get data for.</desc>14044 <desc>Which listener to get data for.</desc> 14046 14045 </param> 14047 14046 <param name="timeout" type="long" dir="in"> 14048 <desc>Timeout to wait until event available in ms, 0 - no wait, -1 - forever until available.</desc> 14047 <desc> 14048 Maximum time to wait for events, in ms; 14049 0 = no wait, -1 = indefinite wait. 14050 </desc> 14049 14051 </param> 14050 14052 <param name="event" type="IEvent" dir="return"> … … 14055 14057 <method name="eventProcessed"> 14056 14058 <desc> 14057 Must be called for waitable events when particular listener finished event processing.14058 When all listeners who this event was aimed to call eventProcessed() event source14059 can call event's setProcessed().14059 Must be called for waitable events after a particular listener finished its 14060 event processing. When all listeners of a particular event have called this 14061 method, the system will then call <link to="IEvent::setProcessed" />. 14060 14062 </desc> 14061 14063 <param name="listener" type="IEventListener" dir="in"> … … 14101 14103 a more specific interface which derives from this (see below). 14102 14104 14103 14104 14105 <b>Introduction to VirtualBox events</b> 14105 14106 14106 Starting with VirtualBox 3.3, support for generic events was introduced. 14107 It provides a uniform mechanism to register for and consume specific events. 14108 Previously, several callback interfaces were used which means that clients 14109 were called for each event in the interface. Also, this mechanism was not 14110 compatible with scripting languages, local Java bindings and remote web 14111 services as they do not support callbacks. 14112 14113 To overcome those issues, the notion of events and listeners was introduced. 14114 Generally speaking, an event represents the information that something happened, 14115 while a listener represents an entity that is interested in certain events. 14116 In order for this to work with unidirectional protocols (i.e. web services), 14117 the concept of passive and active listeners is used. 14107 Generally speaking, an event (represented by this interface) signals that something 14108 happened, while an event listener (see <link to="IEventListener" /> represents an 14109 entity that is interested in certain events. In order for this to work with 14110 unidirectional protocols (i.e. web services), the concepts of passive and active 14111 listener are used. 14118 14112 14119 14113 Event consumers can register themselves as listeners, providing an array of 14120 events they are interested in. When an event triggers, the listener is 14121 notified about the event. The exact mechanism of the notification 14122 depends on the way the listener was registered - as an active or passive listener: 14114 events they are interested in (see <link to="IEventSource::registerListener" />). 14115 When an event triggers, the listener is notified about the event. The exact 14116 mechanism of the notification depends on whether the listener was registered as 14117 an active or passive listener: 14123 14118 14124 14119 <ul> 14125 <li>An active listener is very similar to a traditional callback - i.e. it is a 14126 function invoked by the API implementation. 14127 The main difference here is that there's an event object notion, not individual 14128 callback parameters.</li> 14129 14130 <li>Passive listeners are somewhat trickier: internally the 14131 <link to="IEventSource" /> implementation maintains an event queue for each passive 14132 listener, and newly arrived events are put in this queue. When the listener calls 14133 <link to="IEventSource::getEvent"/>, all elements from its internal event queue are 14134 returned. When the client completes processing of an event, the 14135 <link to="IEventSource::eventProcessed" /> function must be called, acknowledging 14136 that the events were processed. It supports implementing waitable events. On passive 14137 listener unregistration, all events from its queue are auto-acknowledged.</li> 14120 <li>An active listener is very similar to a callback: it is a function invoked 14121 by the API. As opposed to the callbacks that were used in the API before 14122 VirtualBox 3.3 however, events are now objects with an interface hierarchy. 14123 </li> 14124 14125 <li>Passive listeners are somewhat tricker to implement, but do not require 14126 a client function to be callable, which is not an option with scripting 14127 languages or web service clients. Internally the <link to="IEventSource" /> 14128 implementation maintains an event queue for each passive listener, and 14129 newly arrived events are put in this queue. When the listener calls 14130 <link to="IEventSource::getEvent"/>, all elements from its internal event 14131 queue are returned. When the client completes processing of an event, 14132 the <link to="IEventSource::eventProcessed" /> function must be called, 14133 acknowledging that the events were processed. It supports implementing 14134 waitable events. On passive listener unregistration, all events from its 14135 queue are auto-acknowledged. 14136 </li> 14138 14137 </ul> 14139 14138 14140 14139 Waitable events are useful in situations where the event generator wants to track 14141 14140 delivery or a party wants to wait until all listeners have completed the event. A 14142 typical example would be a vetoable event where a listeners might put a veto on 14143 a certain action, and thus the event producer has to make sure that all listeners have 14144 processed the event and not vetoed before taking the action. 14141 typical example would be a vetoable event (see <link to="IVetoEvent" />) where a 14142 listeners might veto a certain action, and thus the event producer has to make 14143 sure that all listeners have processed the event and not vetoed before taking 14144 the action. 14145 14145 14146 14146 A given event may have both passive and active listeners at the same time. … … 14155 14155 For active listeners, such an object is typically created by the consumer, while for 14156 14156 passive listeners <link to="IEventSource::createListener" /> should be used. Please 14157 note that a listener created with @c CreateListener() must not be used as an active listener. 14158 14159 Once created, the listener must be registered to listen for the desired events, providing 14160 an array of <link to="VBoxEventType" /> enums. Those elements can either be the individual 14157 note that a listener created with @c createListener() must not be used as an active listener. 14158 14159 Once created, the listener must be registered to listen for the desired events 14160 (see <link to="IEventSource::registerListener" />), providing an array of 14161 <link to="VBoxEventType" /> enums. Those elements can either be the individual 14161 14162 event IDs or wildcards matching multiple event IDs. 14162 14163 … … 14166 14167 an event processing loop. 14167 14168 14168 Th is interface (IEvent)is an abstract parent interface for all such VirtualBox events14169 The IEvent interface is an abstract parent interface for all such VirtualBox events 14169 14170 coming in. As a result, the standard use pattern inside <link to="IEventListener::handleEvent" /> 14170 14171 or the event processing loop is to check the <link to="#type" /> attribute of the event and … … 14197 14198 <method name="setProcessed"> 14198 14199 <desc> 14199 Called to mark the moment when this event is considered processed. 14200 Internal method called by the system when all listeners of a particular event have called 14201 <link to="IEventSource::eventProcessed" />. This should not be called by client code. 14200 14202 </desc> 14201 14203 </method> … … 14207 14209 </desc> 14208 14210 <param name="timeout" type="long" dir="in"> 14209 <desc>Timeout to wait until event processed in ms, 0 - no wait, -1 - forever until processed.</desc> 14211 <desc> 14212 Maximum time to wait for event processeing, in ms; 14213 0 = no wait, -1 = indefinite wait. 14214 </desc> 14210 14215 </param> 14211 14216 <param name="result" type="boolean" dir="return">
Note:
See TracChangeset
for help on using the changeset viewer.