VirtualBox

Changeset 31116 in vbox


Ignore:
Timestamp:
Jul 26, 2010 2:34:03 PM (15 years ago)
Author:
vboxsync
Message:

Main: event API docs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/idl/VirtualBox.xidl

    r31115 r31116  
    1397113971      <desc>
    1397213972        Register an event listener.
     13973
    1397313974        <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.
    1398013980        </note>
    1398113981      </desc>
     
    1398613986        <desc>
    1398713987          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
    1398913989          than one event.
    1399013990        </desc>
     
    1399813998          listeners. It is then up to the external code to call the listener's
    1399913999          <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" />.
    1400114001        </desc>
    1400214002      </param>
     
    1402214022      <param name="timeout" type="long" dir="in">
    1402314023        <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.
    1402614026        </desc>
    1402714027      </param>
     
    1403314033    <method name="getEvent">
    1403414034      <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
    1404014039        <result name="VBOX_E_OBJECT_NOT_FOUND">
    1404114040          Listener is not registered, or autounregistered.
     
    1404314042      </desc>
    1404414043      <param name="listener" type="IEventListener" dir="in">
    14045         <desc>Which listener get data for.</desc>
     14044        <desc>Which listener to get data for.</desc>
    1404614045      </param>
    1404714046      <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>
    1404914051      </param>
    1405014052      <param name="event" type="IEvent" dir="return">
     
    1405514057    <method name="eventProcessed">
    1405614058      <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 source
    14059         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" />.
    1406014062      </desc>
    1406114063      <param name="listener" type="IEventListener" dir="in">
     
    1410114103      a more specific interface which derives from this (see below).
    1410214104
    14103      
    1410414105      <b>Introduction to VirtualBox events</b>
    1410514106
    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.
    1411814112
    1411914113      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:
    1412314118
    1412414119      <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>
    1413814137      </ul>
    1413914138
    1414014139      Waitable events are useful in situations where the event generator wants to track
    1414114140      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.
    1414514145
    1414614146      A given event may have both passive and active listeners at the same time.
     
    1415514155      For active listeners, such an object is typically created by the consumer, while for
    1415614156      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
    1416114162      event IDs or wildcards matching multiple event IDs.
    1416214163
     
    1416614167      an event processing loop.
    1416714168
    14168       This interface (IEvent) is an abstract parent interface for all such VirtualBox events
     14169      The IEvent interface is an abstract parent interface for all such VirtualBox events
    1416914170      coming in. As a result, the standard use pattern inside <link to="IEventListener::handleEvent" />
    1417014171      or the event processing loop is to check the <link to="#type" /> attribute of the event and
     
    1419714198    <method name="setProcessed">
    1419814199      <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.
    1420014202      </desc>
    1420114203    </method>
     
    1420714209      </desc>
    1420814210      <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>
    1421014215      </param>
    1421114216      <param name="result" type="boolean" dir="return">
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette