The real-time receiver (RealtimeReceiver) is designed for reacting to system-wide events delivered via Intents. It is a subclass of Android’s broadcast receiver class. As Android's receiver, RTDroid's real-time receiver has an abstract function, named onReceive(), which defines logic to react to a system-wide event and is invoked when an Intent is received.
There are two main differences between our real-time receiver and Android’s broadcast receiver. First, we enable programmers to specify the priority, deadline, and memory allowance of each real-time receiver through our manifest extension described further on RTDroid's manifest page. Second, the real-time receiver is persistent, meaning the real-time receiver object is reused to eliminating the de-allocation and reallocation of the real-time receiver for each intent received. As a direct consequence, RTDroid' real-time receiver is capable of only processing one intent at a time without allocating any new receiver objects. In Android a new broadcast receiver is allocated whenever an Intent is received, which results in frequent object allocation and deallocation and flooding of computation if many Intents are sent from a misbehaving component.
Compare to Android's receiver, RTDroid adds a new callback, called onClean(), which is used to clean up or reset all class variables in a real-time receiver. This callback is used to cleanup any state between processing intents and is necessary if a programmer wishes to have a stateless processing of Intents, mirroring Android. We note, however, that the onClean() callback does not need to be leveraged if the receiver only modifies local variables. If onClean() is not used, the programmer can express state that persists between arrivals of Intents because the same real-time receiver is used. Referring back to our CI application example, we can implement OutputReceiver as a real-time receiver. The OutputReceiver would react to the processed audio output sent by the ProcessingService.