Event-based systems comprise a plurality of independent program parts or components that communicate by way of notifications. Events generally correspond to notable conditions that cause a change of state such as sensor output, user action, or component message. In other words, an event is a message that indicates that something has happened. Event-based programs and/or portion thereof begin, wait for events, perform some action, and continue until explicitly terminated. By contrast, batch programs begin, perform an action, and stop.
Event-based programs are implemented with two main components: event triggers and event handlers. Triggers emit a signal or notification upon detecting the occurrence of an event. One or more event handlers respond to this notification by performing an action specific to the event. For example, upon detection of a button click, an event, some functionality is performed related to the click. Stated differently, a sender can detect an event and transmit a notification to a listening receiver, which can perform some designated action.
Furthermore, events are tightly coupled to classes similar to the relationship between a class and a class property. For instance, consider the following exemplary code snippet:
Button b=new Button( );
Here, a new button “b” of type “Button” is constructed. Subsequently, an event “Click” is specified with respect to button “b,” and an event handler “DoSomething( )” is added to this event. Accordingly, both the event and the handler are tied to the “Button” class.
Asynchronous programming is conventionally distinct from event-based programming. Synchronous programming calls for a single execution path. By contrast, asynchronous programming employs multiple execution paths and concurrent operation. More specifically, a caller on a first thread can invoke a callee on a second thread that executes some functionality and returns a result to the caller. Moreover, asynchronous operations do not wait or block for a response from before continuing execution as is done with synchronous operations. Rather, the caller continues operation and is able to accept the result from the callee at anytime. Consequently, asynchronous programming is often employed with respect to time intensive tasks such as connecting to a remote computer and querying a database, among other things.
The following presents a simplified summary in order to provide a basic understanding of some aspects of the disclosed subject matter. This summary is not an extensive overview. It is not intended to identify key/critical elements or to delineate the scope of the claimed subject matter. Its sole purpose is to present some concepts in a simplified form as a prelude to the more detailed description that is presented later.
Briefly described, the subject disclosure pertains to employment of queries in conjunction with event-based processing systems and methods. Furthermore, push-based computation including but not limited to asynchronous programming can be unified under a single event-based framework. In any case, application of queries over events enables concise, declarative, and compositional program specification, among other things.
To enable such functionality, events are lifted to first class status. In other words, rather than being strongly coupled to a class, first-class events can be stored and passed around just as other constructs of such status. These first-class events can then be leveraged to represent various forms of push-based computation as well as support event processing utilizing queries, for example.
To the accomplishment of the foregoing and related ends, certain illustrative aspects of the claimed subject matter are described herein in connection with the following description and the annexed drawings. These aspects are indicative of various ways in which the subject matter may be practiced, all of which are intended to be within the scope of the claimed subject matter. Other advantages and novel features may become apparent from the following detailed description when considered in conjunction with the drawings.
a is a consumer/producer stream diagram illustrating a pull-based model of computation.
b is a consumer/producer stream diagram depicting a push-based model of computation employed by event processing according to a disclosed aspect.
c is a consumer/producer stream diagram illustrating a manner of exception handing according to an aspect of the disclosure.
a-b depict pull based and push based stream representations, respectively, in accordance with an aspect of the claimed subject matter.
a depicts the difference between synchronous and asynchronous programming according to a disclosed aspect.
b is a consumer/producer stream diagram illustrating an event-based representation of asynchronous computing in accordance with an aspect of the disclosure.
a illustrates a consumer/producer stream representation of exemplary discrete events in accordance with an aspect of the disclosure.
b depicts a consumer/producer stream representation of an exemplary continuous event according to a disclosed aspect.
c illustrates a discrete representation of continuous events in accordance with an aspect of the disclosure.
a-b are consumer/producer event streams pertaining to correlated events according to an aspect of the claimed subject matter.
a is a consumer/producer event stream depicting chunking in accordance with an aspect of the disclosure.
b is a consumer/producer event stream illustrating grouping in accordance with an aspect of the disclosed subject matter.
a is a block diagram of an event-based processing system in accordance with an aspect of the disclosure.
b is graphical representation of an example depicting functionality afforded by the event-based processing system of
Systems and methods pertaining to event-based processing are described in detail hereinafter. Push-based computation is unified under a common root, namely event-based processing. For example, both graphical user interface events and asynchronous programming can be processed with respect to events. Furthermore, event-based processing can be transformed into query processing to facilitate composition and orchestration of asynchronous behavior, among other things. Consequently, programmers can express programs that are declarative, compositional, and concise.
Various aspects of the subject disclosure are now described with reference to the annexed drawings, wherein like numerals refer to like or corresponding elements throughout. It should be understood, however, that the drawings and detailed description relating thereto are not intended to limit the claimed subject matter to the particular form disclosed. Rather, the intention is to cover all modifications, equivalents, and alternatives falling within the spirit and scope of the claimed subject matter.
Referring initially to
Turning attention briefly to
Returning to
Furthermore, it should be appreciated that event solutions can be domain specific and require specialized (query/programming) languages for a domain. For example, a language can be designed for event-based graphical user interfaces, or SQL (Structured Query Language) may be employed for event processing in the database world. Here, however, a wide-range of event-based processing approaches can be unified under a common framework. In essence, a commitment to any specific model of how the world works can be avoided. Rather, a set of rich operations for dealing with any form of pushed-based computation is afforded, among other things. Stated differently, query operators can be domain independent.
a and 3b illustrate the difference between push and pull models of computation.
c is a consumer/producer stream diagram illustrating a manner in which failure or exceptions can be handled in accordance with an aspect of the claimed subject matter. As will be further appreciated with respect to latter discussion of asynchronous events, failure can occur anywhere in computation. Conventionally, such failures are termed exceptions and they are treated differently than regular events, especially in a pull-based computation model. In accordance with an aspect of the disclosure, exceptional results and normal results can be unified in the event-based world. As shown, a producer can raise either a normal or an exceptional value. Here, a different stream is employed for exceptional results. However, a single stream can be employed with a disjoint or discriminated union of normal and exceptional results. In any case, it is to be appreciated that handlers can now be added with respect to normal and exceptional results.
a and b depict representations of a push stream 400 and a pull stream 420. The push stream 400 includes a plurality of events 410. The events can be implemented in accordance with an event interface “IEvent<T>,” for example. The pull stream 420 includes numerous events 430, which can be implemented in accordance with a collection interface “IEnumerable<T>.” It is to be noted that both streams 400 and 420 are potentially infinite sequences with deferred execution.
Referring to
While the push and pull sides are operate differently, they have common properties. First, there is a move next style function in the push side producer 510 and the pull side consumer 540. Second, there is deferred execution in the push side consumer 520 and the pull side producer 540. In light of the similar properties, according to an aspect of the claimed subject matter pull-based computations can be converted into push-based computations.
a graphically depicts the difference between synchronous and asynchronous computation. As per synchronous processing 710, a client makes a call to a server to perform some computation and it blocks until the server completes the computation and calls back to the client. Alternatively, with respect to asynchronous processing 710 a client can initiate a computation by a server and continue processing. In other works, the client is unblocked. At some time after initiation, the server can provide the result of the computation back to the client. In one embodiment, a client can provide the server with a callback function to invoke upon completion, although it is not required.
Turning attention to
Conventionally a distinction is also made between so-called discrete events and continuous events. However, in accordance with an aspect of the claimed subject matter these two types of events can be unified.
Continuous or signal-like events can be modeled as edge triggered discrete events, among other things. Rather than having an event maintain a value for a specific period of time, it can be noted when an event acquires a value and then no longer has the value. For example, consider a mouse over event. This could be represented with a single continuous event “mouse on” that has a one value that is valid while the mouse is on or more something. Alternatively, the same functionality can be implemented with two discrete events such a “mouse in” and “mouse out,” where an event is fired when the mouse moves into an area and another event is fired when the mouse moves out of an area.
As shown in
Referring briefly to
a-b depicted consumer/producer event streams pertaining to correlated events in accordance with an aspect of the claimed subject matter. Correlated events are new event streams caused by previous events. Alternatively, correlated events can be termed composite or compositional events for the same reason. A standard sequence operator that that encapsulates correlation is “SelectMany,” sometimes also called “Bind.”
As shown in
b illustrates a more complex use of correlated events. Similar to
This issue, which can also be referred to as a causality error, results from the push and asynchronous nature of the computation. In a normal pull-based system, the consumer is in charge and can determine when things happen. In a push-based setting, however, there is no way to sequence the producers. This ordering issue can be a potential problem. For example consider a dictionary suggest application where as a user types calls are made to a server to return suggestions. Here, server requests can easily come back out of order. Consequently, the application can have stale data presented, if not careful.
The issue is how to deal with cases like the one presented in
Turning attention to
a is a system of event processing 1200 in accordance with an aspect of the claimed subject matter. The system 1200 includes an event construction component 1210 that enables or facilitates construction or composition of an event as a function of sequence and/or query operators, among other things. For example, an event can be composed that includes a superset or subset of one or more source events. Handler addition component 1220 is a mechanism for adding event handlers to a constructed event. In accordance with an aspect of the disclosure, event handlers are composed on source events, rather than on leaf nodes of a constructed event, in a cascading fashion (and can be removed similarly). Furthermore, the system 1200 includes a trigger component 1230 that triggers or raises a constructed event by way of one or more source events.
Turning attention to
While the above example is simple on purpose, it is to be appreciated that the same or analogous functionality can be provided with respect to more complex scenarios enabled by the system 1200 of
Here, two events are constructed utilizing query operations, namely “leftbutton” and “deltas” that is derived from “leftbutton.” Two handlers are added to the “deltas” event. Of course, events can also support many specialized operations, so called “non-proper morphisms.” These include but are not limited to conversions between event streams and convention pull based collections, various grouping and chunking operations, scanning, and parsing.
The aforementioned systems, architectures, and the like have been described with respect to interaction between several components. It should be appreciated that such systems and components can include those components or sub-components specified therein, some of the specified components or sub-components, and/or additional components. Sub-components could also be implemented as components communicatively coupled to other components rather than included within parent components. Further yet, one or more components and/or sub-components may be combined into a single component to provide aggregate functionality. Communication between systems, components and/or sub-components can be accomplished in accordance with either a push and/or pull model. The components may also interact with one or more other components not specifically described herein for the sake of brevity, but known by those of skill in the art.
Furthermore, as will be appreciated, various portions of the disclosed systems above and methods below can include or consist of artificial intelligence, machine learning, or knowledge or rule based components, sub-components, processes, means, methodologies, or mechanisms (e.g., support vector machines, neural networks, expert systems, Bayesian belief networks, fuzzy logic, data fusion engines, classifiers . . . ). Such components, inter alia, can automate certain mechanisms or processes performed thereby to make portions of the systems and methods more adaptive as well as efficient and intelligent. By way of example and not limitation, events and/or event handlers can incorporate such mechanisms.
In view of the exemplary systems described supra, methodologies that may be implemented in accordance with the disclosed subject matter will be better appreciated with reference to the flow charts of
Referring to
Turning attention to
In accordance with an aspect of the disclosure a rich set of algebraic operator, such as query operators, can be employed for event-based processing. These operators have their roots in the mathematical theory of monads. Briefly, a monad allows computation to be described without actually executing the computation. Further, the computation can be parameterized by some type or value. In this case, it is desirous to describe some operations such as queries over event sources or event streams. This implies that what we want is actually a monad. An example of a monad that is familiar is a list or the like. What is described next is how events or streams of events are monads.
Two operations needed for a monad are a unit function and a bind function. Here, the unit function can correspond to the query operator “Return” and the bind function can correspond to the “SelectMany” query operator. As per “Return,” it takes a “T” and returns an “IEvent<T>.” For example, if it is desired that the value five be returned for an event stream, the query operator can return “Event.Return(5).” In this operator “T” is an “INT” and what is returned is “IEvent<INT>” or an event stream of integers. The event stream will have one event, and the value of that event is that provided, namely five. When a handlers is added to this event stream, only one event will fire, which has a value of five. In other words, a value that is not in the monad or event world is injected into the monad or event world. The “Return” operation takes this integer and puts it inside an event stream, so that it can be dealt with through further computations.
Bind or SelectMany is more complicated. In general, bind takes an “IEvent<T>” and a function “T” to “IEvent<U>” and returns “IEvent<U>.” In other words, it takes an event stream and a function that produces a new event stream and outputs the new event stream. Notice that the event streams are parameterized by the event value type they carry. “IEvent<T>” means it carries event values of type “T.” There is no way for anyone to get at that event value directly. In general, this is a key point of monads. If there is something in a monad, in this case an event value, there is no way to access the event value without knowing something about the type that carries the event value. For example, if the monad is a list of “T” and you want to acquire elements in the list, you need to know something about lists. What bind does is it takes the source collection “IEvent<T>” and a function that takes values that are of the type in that collection and produces a new collection with a different value type. This is depicted graphically with respect to
Recall, bind has two parameters, namely a source event stream, which is the top producer line in
The “SelectMany” operator comes into play when there are multiple sources, for instance as shown in
Turning attention to
The word “exemplary” or various forms thereof are used herein to mean serving as an example, instance, or illustration. Any aspect or design described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other aspects or designs. Furthermore, examples are provided solely for purposes of clarity and understanding and are not meant to limit or restrict the claimed subject matter or relevant portions of this disclosure in any manner. It is to be appreciated that a myriad of additional or alternate examples of varying scope could have been presented, but have been omitted for purposes of brevity.
Furthermore, all or portions of the subject innovation may be implemented as a method, apparatus or article of manufacture using standard programming and/or engineering techniques to produce software, firmware, hardware, or any combination thereof to control a computer to implement the disclosed innovation. The term “article of manufacture” as used herein is intended to encompass a computer program accessible from any computer-readable device or media. For example, computer readable media can include but are not limited to magnetic storage devices (e.g., hard disk, floppy disk, magnetic strips . . . ), optical disks (e.g., compact disk (CD), digital versatile disk (DVD) . . . ), smart cards, and flash memory devices (e.g., card, stick, key drive . . . ). Additionally it should be appreciated that a carrier wave can be employed to carry computer-readable electronic data such as those used in transmitting and receiving electronic mail or in accessing a network such as the Internet or a local area network (LAN). Of course, those skilled in the art will recognize many modifications may be made to this configuration without departing from the scope or spirit of the claimed subject matter.
In order to provide a context for the various aspects of the disclosed subject matter,
With reference to
The system memory 1716 includes volatile and nonvolatile memory. The basic input/output system (BIOS), containing the basic routines to transfer information between elements within the computer 1712, such as during start-up, is stored in nonvolatile memory. By way of illustration, and not limitation, nonvolatile memory can include read only memory (ROM). Volatile memory includes random access memory (RAM), which can act as external cache memory to facilitate processing.
Computer 1712 also includes removable/non-removable, volatile/non-volatile computer storage media.
The computer 1712 also includes one or more interface components 1726 that are communicatively coupled to the bus 1718 and facilitate interaction with the computer 1712. By way of example, the interface component 1726 can be a port (e.g., serial, parallel, PCMCIA, USB, FireWire . . . ) or an interface card (e.g., sound, video, network . . . ) or the like. The interface component 1726 can receive input and provide output (wired or wirelessly). For instance, input can be received from devices including but not limited to, a pointing device such as a mouse, trackball, stylus, touch pad, keyboard, microphone, joystick, game pad, satellite dish, scanner, camera, other computer, and the like. Output can also be supplied by the computer 1712 to output device(s) via interface component 1726. Output devices can include displays (e.g., CRT, LCD, plasma . . . ), speakers, printers, and other computers, among other things.
The system 1800 includes a communication framework 1850 that can be employed to facilitate communications between the client(s) 1810 and the server(s) 1830. The client(s) 1810 are operatively connected to one or more client data store(s) 1860 that can be employed to store information local to the client(s) 1810. Similarly, the server(s) 1830 are operatively connected to one or more server data store(s) 1840 that can be employed to store information local to the servers 1830.
Client/server interactions can be utilized with respect with respect to various aspects of the claimed subject matter. By way of example and not limitation, events can be generated by a server 1830 and communicated to a client 1810 across the communication framework 1850. In one specific implementation, such client/server interactions can facilitate asynchronous processing where the server 1830 performs some computation and pushes by the result as an event value to a client 1810 over the communication framework 1850.
What has been described above includes examples of aspects of the claimed subject matter. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the claimed subject matter, but one of ordinary skill in the art may recognize that many further combinations and permutations of the disclosed subject matter are possible. Accordingly, the disclosed subject matter is intended to embrace all such alterations, modifications, and variations that fall within the spirit and scope of the appended claims. Furthermore, to the extent that the terms “includes,” “contains,” “has,” “having” or variations in form thereof are used in either the detailed description or the claims, such terms are intended to be inclusive in a manner similar to the term “comprising” as “comprising” is interpreted when employed as a transitional word in a claim.
This application is related to U.S. patent application Ser. No. ______ [Atty. Ref: MS325083.01/MSFTP2423US, Meijer, et al.], entitled EXCEPTIONAL EVENTS, filed Nov. 25, 2008, U.S. patent application Ser. No. ______ [Atty. Ref: MS325086.01/MSFTP2424US, Dyer, et al.], entitled EXPOSING ASYNCHRONOUS MECHANISMS AS FIRST-CLASS EVENTS, and U.S. patent application Ser. No. ______ [Atty. Ref: MS325085.01/MSFTP2448US, Meijer, et al.], entitled LAZY AND STATELESS EVENTS, all of even date. The entireties of these applications are incorporated herein by reference.