# US 2003/0233485 A1 · Event queue

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2003/0233485 A1
- Document ID: US20030233485A1
- Status: Published application
- Kind: A1
- Application number: 10/170,759
- Filed: 2002-06-13
- Published: 2003-12-18
- Earliest claimed: 2002-06-13
- Assignees: Mircrosoft Corporation
- Inventors: Salahuddin J. Khan
- Web page: https://patentgrep.com/patent/US20030233485A1

## CPC

- G06F 9/4843: {by program, e.g. task dispatcher, supervisor, operating system}
- G06F 9/542: {Event management; Broadcasting; Multicasting; Notifications}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A novel system and method provide for event management utilizing a single thread or a limited plurality of threads to service queued events. When it is desired to add an event to the event queue, a thread is scheduled or acquired, such as from a thread pool, to service queue events unless such a thread is already active, or unless the current number of such threads equals or exceeds a preset thread limit when multiple threads are permitted. The use of a single thread, or alternatively a limited number of threads, to service the event queue leads to economy of system resources, and also avoids memory overflow due to thread proliferation. The limitation on the number of threads created to handle queued events assists in the avoidance of memory overflow complications. In addition, the elimination of threads that would otherwise occupy memory without providing substantial immediate results conserves system resources.

## Claims

### Claim 1

A method of event management in a computing environment via an event queue comprising:
inserting an item into the event queue, wherein the item corresponds to an event to be serviced;
determining whether an event thread is running; and
if it is determined that an event thread is running, forgoing the instantiation of an event thread, and otherwise instantiating an event thread to service the item inserted into the event queue.

### Claim 2 (depends on 1)

The method of event management according to claim 1, wherein determining whether an event thread is running comprises analyzing a flag to determine whether it is set.

### Claim 3 (depends on 1)

The method of event management according to claim 1, wherein instantiating an event thread to service the item inserted into the event queue comprises setting a flag to indicate that the event thread has been instantiated.

### Claim 4 (depends on 1)

The method of event management according to claim 1, wherein the event to be serviced is a network event associated with a network client.

### Claim 5 (depends on 1)

The method of event management according to claim 1, wherein instantiating an event thread to service the item inserted into the event queue further comprises scheduling a new thread.

### Claim 6 (depends on 1)

The method of event management according to claim 1, wherein instantiating an event thread to service the item inserted into the event queue further comprises obtaining a thread from a thread pool.

### Claim 7

A method of managing events in a computing environment via an event queue comprising:
inserting an item into the event queue, wherein the item corresponds to an event to be serviced;
determining whether an event dispatch thread is running;
if it is determined that an event dispatch thread is not running, instantiating an event dispatch thread to service items of the event queue; and
if it is determined that an event dispatch thread is running:
determining a number of event dispatch threads currently running;
comparing the number of event dispatch threads currently running to a preset thread limit;
determining whether the number of event dispatch threads currently running equals or exceeds the preset thread limit; and
if the number of event dispatch threads currently running equals or exceeds the preset thread limit, forgoing the instantiation of an event dispatch thread, and otherwise instantiating an event dispatch thread to service items of the event queue.

### Claim 8 (depends on 7)

The method of managing events according to claim 7, wherein the event to be serviced is a network event associated with a network client.

### Claim 9 (depends on 7)

The method of managing events according to claim 7, wherein determining a number of event dispatch threads currently running further comprises inspecting a thread count field maintaining an indication of the number of event dispatch threads currently running.

### Claim 10 (depends on 9)

The method of managing events according to claim 9, wherein instantiating an event dispatch thread to service items of the event queue further comprises augmenting the thread count value by one.

### Claim 11 (depends on 7)

The method of managing events according to claim 7, wherein instantiating an event dispatch thread to service items of the event queue further comprises scheduling a new thread.

### Claim 12 (depends on 7)

The method of managing events according to claim 7, wherein instantiating an event dispatch thread to service items of the event queue further comprises obtaining a thread from a thread pool.

### Claim 13

A method of servicing an event comprising:
inserting an item into an event listing, wherein the item corresponds to the event, whereby the event listing contains an item corresponding to each of one or more events;
determining whether a thread for servicing any of the one or more events is running; and
starting a thread for servicing any of the one or more events it is determined that such a thread is not running, and otherwise not starting a thread for servicing any of the one or more events.

### Claim 14 (depends on 13)

The method according to claim 13, further comprising servicing by the thread of the one or more items in the event listing in temporal order of insertion.

### Claim 15 (depends on 14)

The method according to claim 14, further comprising establishing that there exist no more items in the event listing to be serviced, and thereafter destroying the event listing.

### Claim 16 (depends on 13)

The method according to claim 13, wherein determining whether a thread for servicing any of the one or more events is running comprises analyzing a flag to determine whether it has been set, whereby if the flag has been set then such a thread is running.

### Claim 17 (depends on 16)

The method according to claim 16, wherein starting a thread for servicing any of the one or more events comprises setting the flag to indicate that such a thread has been started.

### Claim 18 (depends on 13)

The method according to claim 13, wherein starting a thread for servicing any of the one or more events further comprises obtaining a thread from a thread pool.

### Claim 19

A method of servicing an event comprising:
placing an item into an event listing, wherein the item corresponds to an event to be serviced, and whereby the event listing contains an item corresponding to each of one or more events listed in their temporal order of insertion into the listing;
determining whether at least one thread for servicing any of the one or more events is running;
starting a thread for servicing any of the one or more events it is determined that at least one such thread is not running; and
if it is determined that at least one thread for servicing any of the one or more events is running:
determining a number of such threads currently running;
comparing the number of such threads currently running to a thread count maximum value, and thereby determining whether the number of such threads currently running equals or exceeds the thread count maximum value; and
if the number of such threads currently running equals or exceeds the thread count maximum value, forgoing starting another thread for servicing any of the one or more events, and otherwise starting a thread for servicing any of the one or more events.

### Claim 20 (depends on 19)

The method according to claim 19, wherein determining a number of such threads currently running further comprises observing a thread count value indicating the number of such threads currently running.

### Claim 21 (depends on 20)

The method of managing events according to claim 20, wherein starting a thread for servicing any of the one or more events further comprises increasing the thread count value.

### Claim 22 (depends on 19)

The method according to claim 19, wherein starting a thread for servicing any of the one or more events further comprises reserving a thread from a thread pool.

### Claim 23

A system for servicing events comprising:
an event queue comprising a listing of a plurality of events to be serviced; and
a single event handler thread for servicing the plurality of events one at a time.

### Claim 24 (depends on 23)

The system according to claim 23, wherein the single event handler thread services the plurality of events in the temporal order that the events were inserted into the queue.

### Claim 25 (depends on 23)

The system according to claim 23, further comprising a thread flag, whereby the thread flag is in a set condition while the single event handler thread is running and in an unset condition while the single event handler thread is not running, such that insertion of another event into the listing of the event queue causes the thread flag to be observed, thereby assuring that a further event handler thread is not started while the single event handler thread is running.

### Claim 26

A computer-readable medium having thereon computer-readable instructions for performing a method of servicing an event, the method comprising:
placing an item into an event listing, wherein the item corresponds to an event to be serviced, and whereby the event listing contains an item corresponding to each of one or more events listed in their temporal order of insertion into the listing;
determining whether at least one thread for servicing any of the one or more events is running;
starting a thread for servicing any of the one or more events it is determined that at least one such thread is not running; and
if it is determined that at least one thread for servicing any of the one or more events is running:
determining a number of such threads currently running;
comparing the number of such threads currently running to a thread count maximum value, and thereby determining whether the number of such threads currently running equals or exceeds the thread count maximum value; and
if the number of such threads currently running equals or exceeds the thread count maximum value, forgoing starting another thread for servicing any of the one or more events, and otherwise starting a thread for servicing any of the one or more events.

### Claim 27 (depends on 26)

The computer-readable medium according to claim 26, wherein starting a thread for servicing any of the one or more events further comprises increasing the thread count value.

### Claim 28

A computer readable medium having thereon a data structure comprising:
an event queue field having stored therein an event queue comprising a listing of a plurality of events to be serviced; and
a thread structure corresponding to a single event handler thread for servicing the plurality of events one at a time.

### Claim 29 (depends on 28)

The computer readable medium according to claim 28, further comprising a thread flag field having stored therein a thread flag, whereby the thread flag is in a set condition while the single event handler thread is running and in an unset condition while the single event handler thread is not running, such that insertion of another event into the listing of the event queue causes the thread flag to be observed, thereby assuring that a further event handler thread is not started while the single event handler thread is running.
