|
From: | David White |
Subject: | Re: [Wesnoth-dev] possible game_events cleanup |
Date: | Sun, 06 Mar 2005 15:39:55 -0600 |
User-agent: | Mozilla Thunderbird 0.8 (Windows/20040913) |
Yann Dirson wrote:
This idiom is actually used fairly often in Wesnoth, and it's a legitimate one imho.The thing that strikes me much in game_events is that game_events::manager is not a class, but a struct, whose ctor and dtor deal with variables in the anonymous namespace, instead of using object members. The whole thing therefor looks a bit non-reentrant - is there a particular reason. Could it be that there was a start of a move to a full-fledged game_events::manager class, which has not been completed yet ?
The variables aren't members of the manager class because that doesn't make logical sense -- they are completely private to the module and the manager doesn't manipulate them other than setting them up and destroying them when things are done. The manager is simply an exception-safe implementation of the C-style module_init() and module_deinit() idiom.
If re-entrance is desired (and I can understand an argument for it always being wanted), then we can simply add a boolean flag to tell if a manager object is already active, and to make the manager do nothing if a manager is already active. See network::manager for an example of this. Other than possible adding of support for re-entrance, I don't see any reason to change the fundamental functionality of game_events::manager.
David
[Prev in Thread] | Current Thread | [Next in Thread] |