@startuml
!theme plain
title DatarouterMessageClientImpl::ConnectToDatarouter

partition "DatarouterMessageClientImpl::ConnectToDatarouter" {
    start

    :Block termination Signal;
    note right
        **Note:**
        The logger thread (owned by adaptive application)
        should not react to the Terminate Signal. Instead
        the Terminate Signal should be handled by
        mw::lifecycle for Adaptive applications.
    end note

    :Create sender;

    :Start receiver;

    if (Receiver started?) then (Yes)
        if (Is exit requsted?) then (No)
            :Send connect message;
        else (Yes)
        endif
    else (No)
        :Unlink shared memory file;
        :Request stop for connection;
        :Shutdown thread pool;
    endif

    stop
}

@enduml
