[omniORB] How to handle making copies of CORBA object.
Mark Johnson
mark.johnson@onfiber.com
Thu, 30 Aug 2001 10:18:02 -0500
Ok, I think I got this figured out. It was correct for Event to be a struct
since this is just a data package that is being passed around. My confusion
was that I was treating it as a distributed object which doesn't make sense
to do so here. This is the reason why when the caller exited the reciever
core dumped since I was treating the Event as a distributed object and the
servant had exiting - consequently making the Event "service" unavailable...
> -----Original Message-----
> From: Mark Johnson
> Sent: Thursday, August 30, 2001 9:01 AM
> To: OmniOrb Mailing List (E-mail)
> Subject: [omniORB] How to handle making copies of CORBA object.
>
>
> I have defined two interfaces Event and Controller. The
> Controller has a
> method called EventNotify( Event_ptr ). In that method, I
> create a thread
> to process the event, but I need to make a copy of the event since the
> sender might no longer be available after sending the event.
>
> I tried dong the following:
> void Controller_i::EventNotify( Event_ptr aEvent )
> {
> omni_thread::create( theThreadFunc,
> (void*)Event::duplicate(aEvent),
> omni_thread::PRIORITY_HIGH );
> }
> But if the caller of controller->EventNotify() runs its
> course and exits,
> the callee will core dump.
>
>
> However, if I change Event to a struct and new the event
> everything works
> great event if the caller exits:
> void Controller_i::EventNotify( const Event& aEvent )
> {
> Event * event = new Event;
> CopyEvent( event, aEvent );
> omni_thread::create( theThreadFunc, (void*)event,
> omni_thread::PRIORITY_HIGH );
> }
>
> Which is the correct way of doing this. Is it possible to
> create a copy of
> the Event interface such that when the servant exits the
> objects recieved at
> the client are still valid? I would expect that I should
> have to use an
> Event_var to take advantage of the reference counting, but
> the idl compiler
> generated an Event_ptr for EventNotify(). I'm sure that
> somewhere between
> the invokation of EventNotify() and the spawning of the
> thread I need to
> create an Event_var but I don't understand the process of how
> to do that.
>
> thanks for your help....
>