Discussion:
[omniORB] Sequence of valuetypes in C++
Tamas Kerecsen
2006-09-06 10:42:41 UTC
Permalink
Hi everyone,

I've noticed an odd behavior when I started experimenting with valuetypes. I
have a sequence that contains valuetype objects. When I set values in the
sequence (doing something like seq[0] = obj1), the reference count of the
objects are not incremented. However when the sequence goes out of scope, it
decrements the reference count of all the objects contained within. This is
asymmetrical.

All the rest of the C++ mapping seems to function intuitively (meaning that
you can use _var smart pointers for everything and never have to use
pointers, or call add_ref or remove_ref directly) except for this sequence
case, and the case of _downcast.

Is this behavior intentional? Is this a bug (improvement opportunity :)) in
the corba spec? Please don't hesitate to share any opinions/speculation!

Thanks,
Tamas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20060905/c49bdc96/attachment.htm
Duncan Grisby
2006-09-06 23:02:24 UTC
Permalink
Post by Tamas Kerecsen
I've noticed an odd behavior when I started experimenting with valuetypes. I
have a sequence that contains valuetype objects. When I set values in the
sequence (doing something like seq[0] = obj1), the reference count of the
objects are not incremented. However when the sequence goes out of scope, it
decrements the reference count of all the objects contained within. This is
asymmetrical.
That is exactly the same as the behaviour with object references.
Post by Tamas Kerecsen
All the rest of the C++ mapping seems to function intuitively (meaning that
you can use _var smart pointers for everything and never have to use
pointers, or call add_ref or remove_ref directly) except for this sequence
case, and the case of _downcast.
You can do the same with valuetypes. As long as you are holding your
values in _vars, their reference counts are incremented when they are
put into sequences.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Tamas Kerecsen
2006-09-07 10:00:52 UTC
Permalink
Duncan,

Indeed, you are right. It never occured to me that the assignment would be
different in case of vars than for pointers, but apparently it is. Thanks a
lot for the help!

Tamas

ps: Do you have any clue when the final 4.1 will be coming out?


You can do the same with valuetypes. As long as you are holding your
Post by Duncan Grisby
values in _vars, their reference counts are incremented when they are
put into sequences.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20060906/a0ce23cb/attachment.htm
Continue reading on narkive:
Search results for '[omniORB] Sequence of valuetypes in C++' (Questions and Answers)
5
replies
can i get question answer of asp.net ?
started 2006-10-11 00:02:47 UTC
software
Loading...