This might be about the coolest site I've ever seen. Anyway, diplomacy is over-rated
I don't disagree at all about the performance hit. I came up with the C++ object just to pack all of whatever it's gonna do into something that can be tucked away in a generic library and offer an easy way to trigger something. I like it because it keeps all the dirty work of checking the clock out of the main code. So, the utility can look something like:
// xxx is each of sound, graphics_cache, file_activity, port_status, whatever_else
struct xxx_Manager : Chronisitcs
{
xxx_Manager(int ms) : Chronistics(ms) {}
virtual bool operator()();
}
bool xxx_Manager:

perator()()
{
if (!trigger()) return false;
// it's time to do whatever an xxx manager should do
return true;
}
while (1)
{
// just do whatever you normally do...
// each line turns out to be a function object based on the Chonistics thingy
sound_manager();
graphic_cache_manager();
geometry_manager();
collision_manager();
file_activity_manager();
port_status_manager();
magic_spell_manager();
socket_service_manager();
whatever_else_manager();
// probably need some kind of system call here or you'll tank.
// usually a short sleep does the trick.
usleep(10);
}
...and all the logic of determining when to actually do the stuff is handled in the Chronistic guts. However it's done, it happens exactly the same way for every Chronistic derivative. And, of course then, you can have stacks and deques and maps of managed objects, and traverse them, sort them, update them in whatever order you want, index them, well, you get the point. It can get pretty interesting.
But, what I really want to know is, what is the best way to get the kernel to signal something periodically. And, can it be done without a worker thread?