 |
Modification to #2
> > There are two (or three) errata in the Streams example > in C++NPv2 on p302. > > When a module contains a member variable task that it > passes to its base class: > > Given the following typedef: > > typedef ACE_Module parent; > > 1. The base class default constructor must be used in > the constructor initialization list (i.e., don't put > anything in the constructor list, or put parent() to > be explicit about it), and then the base > class parent::open() function should be used in the > body of the derived module constructor to pass > the address of the member variable task. > > This ensures that the member variable task has > finished construction before being passed to the > base class. > > 2. The derived module must implement a destructor, > and that destructor must call parent::close(). > This removes any reference to the member > variable in the base class, and avoids a SEGV > when the base class destructor is closed.
Just calling close() (inherited) is ok.
The code in Module.cpp, close_i, makes a call task->module_closed() which will SEGV if the base class destructor calls close_i() since the inherited class has already been destroyed (it contained the member class referred to by this task pointer).
> 3. A possible third errata is that the flag passed > to the base class tells the base class parent::close() > which task to delete. In the example, no tasks should > be deleted, so the flag should probably > be parent::M_DELETE_NONE. > > Regards > Dave > >
|
|