Re: [OMPI devel] [OMPI svn] svn:open-mpi r28029 - trunk/opal/class

2013-02-04 Thread Jeff Squyres (jsquyres)
I think the point is that there are many cases throughout the OMPI code base 
where we do exactly the things listed in these macros.

You certainly don't have to use them, but they can save a little effort when 
you them.


On Feb 4, 2013, at 2:13 PM, George Bosilca  wrote:

> Ralph,
> 
> There are valid reasons why we decided not to add such macros.
> 
> Adding elements to a list do not increase the element ref count.
> Similarly, removing an element from a list does not decrease its
> refcount either. Thus, there is no obvious link between the refcount
> of the elements in a list and the list itself. As a result, we can not
> make the assumption that decreasing the refcount by one is correct,
> and this even when we plan to get rid of one of our lists.
> 
> In addition, the list can contain elements that have been
> OBJ_CONSTRUCT in which case this macro will lead to unexpected
> behaviors.
> 
>  George.
> 
> 
> On Mon, Feb 4, 2013 at 2:42 PM,   wrote:
>> Author: rhc (Ralph Castain)
>> Date: 2013-02-04 14:42:57 EST (Mon, 04 Feb 2013)
>> New Revision: 28029
>> URL: https://svn.open-mpi.org/trac/ompi/changeset/28029
>> 
>> Log:
>> The opal_list_t destructor doesn't release the items on the list prior to 
>> destructing or releasing it. Provide two convenience macros for doing so.
>> 
>> Text files modified:
>>   trunk/opal/class/opal_list.h |26 ++
>>   1 files changed, 26 insertions(+), 0 deletions(-)
>> 
>> Modified: trunk/opal/class/opal_list.h
>> ==
>> --- trunk/opal/class/opal_list.hMon Feb  4 12:36:55 2013
>> (r28028)
>> +++ trunk/opal/class/opal_list.h2013-02-04 14:42:57 EST (Mon, 04 Feb 
>> 2013)  (r28029)
>> @@ -160,6 +160,32 @@
>>  */
>> typedef struct opal_list_t opal_list_t;
>> 
>> +/** Cleanly destruct a list
>> + *
>> + * The opal_list_t destructor doesn't release the items on the
>> + * list - so provide two convenience macros that do so and then
>> + * destruct/release the list object itself
>> + *
>> + * @param[in] list List to destruct or release
>> + */
>> +#define OPAL_LIST_DESTRUCT(list)\
>> +do {\
>> +opal_list_item_t *it;   \
>> +while (NULL != (it = opal_list_remove_first(list))) {   \
>> +OBJ_RELEASE(it);\
>> +}   \
>> +OBJ_DESTRUCT(list); \
>> +} while(0);
>> +
>> +#define OPAL_LIST_RELEASE(list) \
>> +do {\
>> +opal_list_item_t *it;   \
>> +while (NULL != (it = opal_list_remove_first(list))) {   \
>> +OBJ_RELEASE(it);\
>> +}   \
>> +OBJ_RELEASE(list);  \
>> +} while(0);
>> +
>> 
>> /**
>>  * Loop over a list.
>> ___
>> svn mailing list
>> s...@open-mpi.org
>> http://www.open-mpi.org/mailman/listinfo.cgi/svn
> ___
> devel mailing list
> de...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/devel


-- 
Jeff Squyres
jsquy...@cisco.com
For corporate legal information go to: 
http://www.cisco.com/web/about/doing_business/legal/cri/




Re: [OMPI devel] [OMPI svn] svn:open-mpi r28029 - trunk/opal/class

2013-02-04 Thread George Bosilca
Ralph,

There are valid reasons why we decided not to add such macros.

Adding elements to a list do not increase the element ref count.
Similarly, removing an element from a list does not decrease its
refcount either. Thus, there is no obvious link between the refcount
of the elements in a list and the list itself. As a result, we can not
make the assumption that decreasing the refcount by one is correct,
and this even when we plan to get rid of one of our lists.

In addition, the list can contain elements that have been
OBJ_CONSTRUCT in which case this macro will lead to unexpected
behaviors.

  George.


On Mon, Feb 4, 2013 at 2:42 PM,   wrote:
> Author: rhc (Ralph Castain)
> Date: 2013-02-04 14:42:57 EST (Mon, 04 Feb 2013)
> New Revision: 28029
> URL: https://svn.open-mpi.org/trac/ompi/changeset/28029
>
> Log:
> The opal_list_t destructor doesn't release the items on the list prior to 
> destructing or releasing it. Provide two convenience macros for doing so.
>
> Text files modified:
>trunk/opal/class/opal_list.h |26 ++
>1 files changed, 26 insertions(+), 0 deletions(-)
>
> Modified: trunk/opal/class/opal_list.h
> ==
> --- trunk/opal/class/opal_list.hMon Feb  4 12:36:55 2013
> (r28028)
> +++ trunk/opal/class/opal_list.h2013-02-04 14:42:57 EST (Mon, 04 Feb 
> 2013)  (r28029)
> @@ -160,6 +160,32 @@
>   */
>  typedef struct opal_list_t opal_list_t;
>
> +/** Cleanly destruct a list
> + *
> + * The opal_list_t destructor doesn't release the items on the
> + * list - so provide two convenience macros that do so and then
> + * destruct/release the list object itself
> + *
> + * @param[in] list List to destruct or release
> + */
> +#define OPAL_LIST_DESTRUCT(list)\
> +do {\
> +opal_list_item_t *it;   \
> +while (NULL != (it = opal_list_remove_first(list))) {   \
> +OBJ_RELEASE(it);\
> +}   \
> +OBJ_DESTRUCT(list); \
> +} while(0);
> +
> +#define OPAL_LIST_RELEASE(list) \
> +do {\
> +opal_list_item_t *it;   \
> +while (NULL != (it = opal_list_remove_first(list))) {   \
> +OBJ_RELEASE(it);\
> +}   \
> +OBJ_RELEASE(list);  \
> +} while(0);
> +
>
>  /**
>   * Loop over a list.
> ___
> svn mailing list
> s...@open-mpi.org
> http://www.open-mpi.org/mailman/listinfo.cgi/svn