 | 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.
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
|
|