Learn something new every day More Info... by email
In computer programming and engineering, an active object is a type of design pattern that can be used to help ensure that some service is always available in a multi-threaded or concurrent system. An active object is an object that implements a mechanism so it can receive and process input from external objects without forcing the external objects to wait for execution to complete. This mechanism also allows many objects that might all be running concurrently to use active objects without the possibility for long blocking times in which the concurrent processes must stop and wait for access. This most often is achieved by wrapping the active objects in a publicly accessible interface, called a proxy, and then implementing a type of queue system inside the objects so messages are stored for later processing. This creates a design pattern in which objects send messages to active objects and then continue their processing until the active object processes the message and later informs the calling objects of the results so they can update their states accordingly.
Outside an active object design pattern, a normal object might be called a passive object. In a simple program example, a passive object might be acting as a chat server relay, in which remote objects contact the passive object to transmit a message to everyone else on the server. Whenever the passive server object receives a chat message from a remote object, it must handle the request immediately and then immediately send output, all while the remote object halts its own execution until the process is done, an effect known as blocking. Creating different threads within the program can solve the problem of execution blocking but then initiates problems with synchronization.
In an active object design pattern, the same server object in the above example would be running in its own thread separate from the other objects. It also would be wrapped in some type of interface known as a proxy that also is running in a separate thread, sometimes the main program execution thread. When a remote object wants to have the server object send out a chat message, it contacts the proxy object, passes to it all of the information required, and then returns to its normal execution state instead of waiting.
The proxy interface then converts the information from the remote object into a message that it passes to a queue for the active object to process. At this point, both the proxy interface and the remote object are free to continue executing and are not blocked. Meanwhile, the active object works to keep the queue empty, processing each incoming message. If the calling object requires some information to be returned by the active object, then a callback structure can be used to inform the remote object of any changes in state.
One of our editors will review your suggestion and make changes if warranted. Note that depending on the number of suggestions we receive, this can take anywhere from a few hours to a few days. Thank you for helping to improve wiseGEEK!