Hi Praveen,

ack, code review only, nice use of count_if. Minor comments below.

/Thanks HansN

On 11/09/2015 10:41 AM, praveen.malv...@oracle.com wrote:
>   osaf/services/saf/amf/amfd/include/sg.h |   7 +++++++
>   osaf/services/saf/amf/amfd/sg.cc        |  21 +++++++++++++++++++++
>   2 files changed, 28 insertions(+), 0 deletions(-)
>
>
> After SG lock, immlist <sg> does not show correct value of 
> saAmfSGNumCurrAssignedSUs.
>
> AMFD is not calculcating dynamically the values of following runtime
> attributes:
> saAmfSGNumCurrNonInstantiatedSpareSUs,
> saAmfSGNumCurrInstantiatedSpareSUs and
> saAmfSGNumCurrAssignedSUs
> in sg_rt_attr_cb().
>
> Patch fixes the problem by  providing updated values in IMM callback.
>
> diff --git a/osaf/services/saf/amf/amfd/include/sg.h 
> b/osaf/services/saf/amf/amfd/include/sg.h
> --- a/osaf/services/saf/amf/amfd/include/sg.h
> +++ b/osaf/services/saf/amf/amfd/include/sg.h
> @@ -417,6 +417,13 @@ public:
>       bool ng_using_saAmfSGAdminState;
>       
>       uint32_t term_su_list_in_reverse();
> +       //Runtime calculates value of saAmfSGNumCurrAssignedSUs;
[HansN] Use const for these functions.

uint32_t curr_assigned_sus() const;
//Runtime calculates value of saAmfSGNumCurrInstantiatedSpareSUs;
uint32_t curr_instantiated_spare_sus() const;
//Runtime calculates value of saAmfSGNumCurrNonInstantiatedSpareSUs;
uint32_t curr_non_instantiated_spare_sus() const;



> +     uint32_t curr_assigned_sus();
> +     //Runtime calculates value of saAmfSGNumCurrInstantiatedSpareSUs;
> +     uint32_t curr_instantiated_spare_sus();
> +     //Runtime calculates value of saAmfSGNumCurrNonInstantiatedSpareSUs;
> +     uint32_t curr_non_instantiated_spare_sus();
> +
>   private:
>       // disallow copy and assign, TODO(hafe) add common macro for this
>       AVD_SG(const AVD_SG&);
> diff --git a/osaf/services/saf/amf/amfd/sg.cc 
> b/osaf/services/saf/amf/amfd/sg.cc
> --- a/osaf/services/saf/amf/amfd/sg.cc
> +++ b/osaf/services/saf/amf/amfd/sg.cc
> @@ -1428,12 +1428,15 @@ static SaAisErrorT sg_rt_attr_cb(SaImmOi
>   
>       while ((attributeName = attributeNames[i++]) != NULL) {
>               if (!strcmp("saAmfSGNumCurrAssignedSUs", attributeName)) {
> +                     sg->saAmfSGNumCurrAssignedSUs = sg->curr_assigned_sus();
>                       avd_saImmOiRtObjectUpdate_sync(objectName, 
> attributeName,
>                               SA_IMM_ATTR_SAUINT32T, 
> &sg->saAmfSGNumCurrAssignedSUs);
>               } else if (!strcmp("saAmfSGNumCurrNonInstantiatedSpareSUs", 
> attributeName)) {
> +                     sg->saAmfSGNumCurrNonInstantiatedSpareSUs = 
> sg->curr_non_instantiated_spare_sus();
>                       avd_saImmOiRtObjectUpdate_sync(objectName, 
> attributeName,
>                               SA_IMM_ATTR_SAUINT32T, 
> &sg->saAmfSGNumCurrNonInstantiatedSpareSUs);
>               } else if (!strcmp("saAmfSGNumCurrInstantiatedSpareSUs", 
> attributeName)) {
> +                     sg->saAmfSGNumCurrInstantiatedSpareSUs = 
> sg->curr_instantiated_spare_sus();
>                       avd_saImmOiRtObjectUpdate_sync(objectName, 
> attributeName,
>                               SA_IMM_ATTR_SAUINT32T, 
> &sg->saAmfSGNumCurrInstantiatedSpareSUs);
>               } else {
> @@ -1987,3 +1990,21 @@ AVD_SU* AVD_SG::first_su()
>               return NULL;
>       }
>   }
[HansN] In c++11 cbegin and cend can be used for constant iterators, so:

uint32_t AVD_SG::curr_assigned_sus() const
{
     return (std::count_if (list_of_su.cbegin(), list_of_su.cend(),
                 [](AVD_SU *su) -> bool { return (su->list_of_susi != 
nullptr);}));
}
uint32_t AVD_SG::curr_instantiated_spare_sus() const
{
     return (std::count_if (list_of_su.cbegin(), list_of_su.cend(),
                 [](AVD_SU *su) -> bool { return ((su->list_of_susi == 
nullptr) &&
                         (su->saAmfSUPresenceState == 
SA_AMF_PRESENCE_INSTANTIATED));}));
}
uint32_t AVD_SG::curr_non_instantiated_spare_sus() const
{
     return (std::count_if (list_of_su.cbegin(), list_of_su.cend(),
         [](AVD_SU *su) -> bool { return ((su->list_of_susi == nullptr) &&
             (su->saAmfSUPresenceState == 
SA_AMF_PRESENCE_UNINSTANTIATED));}));
}

+
+uint32_t AVD_SG::curr_assigned_sus()
+{
+       return (std::count_if (list_of_su.begin(), list_of_su.end(),
+                [](AVD_SU *su) -> bool { return (su->list_of_susi != 
nullptr);}));
+}
+uint32_t AVD_SG::curr_instantiated_spare_sus()
+{
+       return (std::count_if (list_of_su.begin(), list_of_su.end(),
+                [](AVD_SU *su) -> bool { return ((su->list_of_susi == nullptr) 
&&
+                        (su->saAmfSUPresenceState == 
SA_AMF_PRESENCE_INSTANTIATED));}));
+}
+uint32_t AVD_SG::curr_non_instantiated_spare_sus()
+{
+       return (std::count_if (list_of_su.begin(), list_of_su.end(),
+               [](AVD_SU *su) -> bool { return ((su->list_of_susi == nullptr) 
&&
+                       (su->saAmfSUPresenceState == 
SA_AMF_PRESENCE_UNINSTANTIATED));}));      
+}


> +
> +uint32_t AVD_SG::curr_assigned_sus()
> +{
> +     return (std::count_if (list_of_su.begin(), list_of_su.end(),
> +                [](AVD_SU *su) -> bool { return (su->list_of_susi != 
> nullptr);}));
> +}
> +uint32_t AVD_SG::curr_instantiated_spare_sus()
> +{
> +     return (std::count_if (list_of_su.begin(), list_of_su.end(),
> +                [](AVD_SU *su) -> bool { return ((su->list_of_susi == 
> nullptr) &&
> +                        (su->saAmfSUPresenceState == 
> SA_AMF_PRESENCE_INSTANTIATED));}));
> +}
> +uint32_t AVD_SG::curr_non_instantiated_spare_sus()
> +{
> +     return (std::count_if (list_of_su.begin(), list_of_su.end(),
> +             [](AVD_SU *su) -> bool { return ((su->list_of_susi == nullptr) 
> &&
> +                     (su->saAmfSUPresenceState == 
> SA_AMF_PRESENCE_UNINSTANTIATED));}));      
> +}


------------------------------------------------------------------------------
Go from Idea to Many App Stores Faster with Intel(R) XDK
Give your users amazing mobile app experiences with Intel(R) XDK.
Use one codebase in this all-in-one HTML5 development environment.
Design, debug & build mobile apps & 2D/3D high-impact games for multiple OSs.
http://pubads.g.doubleclick.net/gampad/clk?id=254741551&iu=/4140
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to