API Reference | developer.brewmp.com API Reference | developer.brewmp.com

Developer

API Reference

IENV

Brew Release
Brew MP 1.0.2
See Also
Description

This interface provides the basic set of services a component typically requires to be instantiated and initialized: memory allocation and creation of other objects.
There are two types of objects supporting IEnv that are commonly encountered in the system: "Env" objects, and "ModEnv" objects.
An Env, or environment, is the component infrastructure surrounding the object, and establishes a context within which objects exist. There is one Env created for each each process or applet when it is started. At any one time, a thread is considered to be "inside" a particular Env.
Objects that reside within the same Env are "local" to each other: they can invoke each other without passing through remote invocation gateways, they may directly share objects and pointers, and they may trade off responsibility for freeing allocated memory. Objects that reside in different Envs will typically communicate only through remote invocation (via remotable APIs), although this is strictly enforced only when the Env is associated with a process. Each Env has a set of privileges that dictates which remote services is can obtained.
A ModEnv represents an instance of a module (an executable code and data image that implements a set of classes) within an Env. When a module is loaded within an Env, a ModEnv is created. The ModEnv is mainly used to track references to the module, but it can also be used to store module-local data. For convenience it re-exposes the functionality of the surrounding Env (memory allocation and object creation).
When an object is created by the component infrastructure, an IEnv reference is passed to its CreateInstance() function. This IEnv is an interface to the ModEnv object, not to the Env. Each new object is expected to AddRef this IEnv and hold that reference until it is deleted (when its reference count goes to zero). After the last object implemented in the module releases its IEnv, the module code and data may be removed from memory.
The env_CreateInstance() function, on the other hand, utilizes the current Env. Since the ModEnv re-exposes the functionality of its surrounding Env, object creation through env_CreateInstance() or IEnv_CreateInstance() should behave equivalently (although using IEnv will avoid context recovery and may be faster as a result).