VirtualBox

Ignore:
Timestamp:
Oct 28, 2010 8:56:39 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
67138
Message:

SDK manual: event aggregation explanation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/en_US/SDKRef.xml

    r33461 r33538  
    21032103      support callbacks. The new mechanism with events and event listeners
    21042104      works with all of these.</para>
     2105      <para>To simplify developement of application using events,
     2106      concept of event aggregator was introduced. Essentially it's
     2107      mechanism to aggregate multiple event sources into single one,
     2108      and then work with this single aggregated event source instead of
     2109      original sources. As an example, one can evaluate demo recorder
     2110      in VirtualBox Python shell, shipped with SDK - it records mouse
     2111      and keyboard events, represented as separate event sources.
     2112      Code is essentially like this:<screen>
     2113          listener = console.eventSource.createListener()
     2114          agg = console.eventSource.createAggregator([console.keyboard.eventSource, console.mouse.eventSource])
     2115          agg.registerListener(listener, [ctx['global'].constants.VBoxEventType_Any], False)
     2116          registered = True
     2117          end = time.time() + dur
     2118          while  time.time() < end:
     2119              ev = agg.getEvent(listener, 1000)
     2120              processEent(ev)
     2121          agg.unregisterListener(listener)</screen>
     2122         Without using aggregators consumer have to poll on both
     2123         sources, or start multiple threads to block on those sources.
     2124      </para>
    21052125    </sect1>
    21062126  </chapter>
Note: See TracChangeset for help on using the changeset viewer.

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