Intrusive feature idea - accessor_hook

Intrusive has base_hooks and member_hooks. I wish it had a accessor hook, where you can define a member function which returns the a hook reference. My use case: I have a class being used between two threads and I want to break it up to avoid cache thrashing. struct Object{ struct UpdatedState{ } *updatedState; struct PrivateState{ } *privateState; struct PublishedState{ } *publishedState; }; So the users's thread updates stuff in UpdatedState and flags it for consumption by the service thread. The service thread has lots of private data associated with the object. It updates the user asychronously updating publishedState and flagging it for consumption by the user. The a nice way to flag things for consumption is to put them in an slist. The problem is that everyone wants an slist of Object instead of just a child like UpdatedState. The problem of course is that putting the hooks in Object would cause the cache trashing we were trying to avoid. Putting the hooks in the child objects requires a way back to Object. As work around a pointer could be added for each child back to Object. If I were writing my own linked lists, the solution is obvoius: I would add a field Object* nextUpdated to UpdatedState. What I propose is adding a accessor to Object list_member_hook<>& getUpdatedHook(); typedef accessor_hook

Zitat von "Hite, Christopher"
Intrusive has base_hooks and member_hooks. I wish it had a accessor hook, where you can define a member function which returns the a hook reference.
agreed, I reported this as a "feature request" to Trac a while ago: https://svn.boost.org/trac/boost/ticket/3489 there's also an implementation attached, but I vaguely remember discovering some problems with it later, so in case you end up using it let me know so I can check if it still matches the local code.
participants (2)
-
Hite, Christopher
-
Stefan Strasser