Brew provides a wide range of system services, including application management, resource file management, memory processing, retrieval of device and application configuration information, communication between BREW applications and mobile phones, timers, and alarms, earlier brew3.x versions were mainly implemented through the ishell interface. Brew3.x and later provide ialarmmgr enhanced processing alarms. The iappletctl and iapphistory interfaces further enhance application state management.
The timer is identified by the callback function and the data structure address provided when the timer is created. You can use ishell_settimerex or ishell_settimer; to set the timer. If a time period expires, the time period is automatically canceled. If the time period does not arrive, you can use callback_cancel and ishell_canceltimer to cancel the event. The timer can also be triggered repeatedly, but it must be set again in the timer's callback function. Ishell_gettimerexpiration is used to determine the number of milliseconds remaining before a specific timer expires. The timer is not executed immediately when the specified time is reached, but must wait until the execution of the currently executed function is completed and the callback execution before the other timer callback functions is completed, the timer callback function in the system queue can be executed. Therefore, the timer interval may be greatly prolonged. If you rely on the timer for Time-Dependent operations, pay attention to this.
If brew occupies CPU for a long time, it will reset the mobile phone. Brew 2.1 and later versions provide the ithread interface to adapt to mathematical operations and network data receiving and processing that occupy CPU in depth. Thread provides interfaces for starting and running threads and methods for transferring the CPU usage. A thread function is an infinite or finite loop process. A thread operation must be divided into small computing units for Reciprocating. After each computing unit, the role function must be called:
Ishell_resume (pishell, PCB );
Ithread_suspend (me );
The PCB is obtained as follows:
Ithread * Me;
Aeecallback * PCB = ithread_getresumecbk (me );
The bit function is used to schedule tasks, pause the execution of the current thread, switch to other threads, and restore the count (avoid resetting the mobile phone ). During programming, it is easy to see that the memory is not released after the memory is allocated, resulting in Memory leakage. Similarly, after an object is created, it needs to be released; otherwise, it will also cause memory leakage. Use the irscpool interface to release dynamically allocated memory and resources without having to release them one by one. Irscpool is used to manage resources and allocate memory. As a relatively independent module, ithread may allocate memory and create resources together, and release resources together. Therefore, the irscpool function is most likely to be used in thread applications.
In brew, if the reference count is not zero when an interface is created, the created interface pointer is obtained, and the reference count is incremented. If the reference count is zero, the interface is created. When you delete an interface, the reference count is reduced by one. If the count is reduced to zero, the interface memory is detached from the system memory. All brew interfaces are derived from the iBase interface. The IBASE interface has only two methods: ibaseadref and ibase_release, the two methods of each derived interface are called ixxx_addref and ixxx_release. The following describes why different names can be called by the same interface. After using the interface, remember to use ixxx_release to release it. Otherwise, memory leakage may occur.