RiCHandleCloser class

OSAL interface contains RiCOSTask_endMyTask method which is used if a thread is deleted by itself (for example, if active reactive class entered into terminate connector).

But in some RTOSes it is forbidden for thread perform such operation directly. The RiCHandleCloser class solves this problem. It is an active reactive singleton class with a statechart containing one state. This state receives only one event (CloseEVent ) and performs only one action (doCloseHandle() call) when it is received.

OMHandleClose thread is initialized in the OMOS::initEpilog():

void RiCOSOXFInitEpilog(void)
{
      
(void)RiCHandleCloser_startBehavior(RiCHandleCloser_Instance(RiCInt_doCloseH
andle));
}

If some thread is going to exit it calls (from framework) endMyTask() function which sends CloseEvent message(event) to the HandleCloser thread.

void RiCOSTask_endMyTask( RiC_CONST_TYPE void *const hThread )
{
    if( hThread != NULL )
    {
         RiCHandleCloser_genCloseEvent(hThread);
        Exit( 0UL );
    }
}

This message contains the handle of the thread, which is deleted.

The doCloseHandle is static function, which is called by HandleCloser thread when CloseEvent event is processed.

You can see HandleCloser usage in Integrity adapter (Share/LangC/oxf/RiCOSIntegrity.c file).

Note: A similar mechanism is implemented in C++ framework.

Feedback