Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Object Pools

  • 03-12-2004 3:57pm
    #1
    Closed Accounts Posts: 1,651 ✭✭✭


    I've written an app that's split into separate modules or managers (Content, List, Security, Users etc).

    When that app starts up it creates one of each of those managers and makes them accessible through a single RootManager object.

    So when I need to create new content I'd say something like this:
    ContentManager cm = (ContentManager)m_rootManager.getManager(CONTENT_MANAGER);
    
    and it's the same for each manager. This works well because I can plug in new managers without having to change any code.

    The problem is that it's a bit of a bottleneck really, there's only one of each of the manager instances and it's a multi-user app. So I'm implementing Object Pools for each of the managers.

    Now when the app starts up it creates a pool for each type of manager (except the RootManager) and makes the pool accessible through the RootManager.

    What should I do with the RootManager?
    Should I create a pool of them and make the pool accessible globally?
    Should I just have a static RootManager.getManager(MANAGER_NAME) method?
    Or should I just leave it as it is, create a RootManager instance and make it globally accessible?

    Or does it even matter?


Comments

  • Closed Accounts Posts: 92 ✭✭tempest


    What should I do with the RootManager?
    Should I create a pool of them and make the pool accessible globally?
    Should I just have a static RootManager.getManager(MANAGER_NAME) method?
    Or should I just leave it as it is, create a RootManager instance and make it globally accessible?

    Or does it even matter?

    It depends on the usage pattern tbh.
    The main question to ask is: Does the root manager contain state within an instance that is inappropriate in a multiuser environment.

    My guess is no... It just manages the other managers and implements the pooling semantics... in which case a static method is fine.. and pooling would have no benefit.

    If there is state associated with the consumer of the root manager then you need to either queue (or fail) requests or implement pooling logic.

    Questions like this usually come down to usage patterns of an object.


  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    Thanks!
    The root manager doesn't have any state so I'll go with the static method.
    I just wasn't too sure whether or not it was a good idea.

    Thanks again.


Advertisement