VirtualBox

Changeset 75861 in vbox for trunk/src/VBox/Main/include


Ignore:
Timestamp:
Dec 2, 2018 12:26:36 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
127065
Message:

Main/Guest: Added a few codereview comments, mainly in the guest base class area. Replaced the object ID management in GuestSession with a classic allocation bitmap approach as that's much less memory intensive than 16 byte structs in a insert-only std::map and an additional map tracking free 32-bit IDs after we run out. bugref:9313

Location:
trunk/src/VBox/Main/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h

    r74734 r75861  
    10781078    int                              GetGuestError(void) const { return mGuestRc; }
    10791079    int                              SignalExternal(IEvent *pEvent);
    1080     const GuestEventTypes            Types(void) { return mEventTypes; }
     1080    const GuestEventTypes           &Types(void) { return mEventTypes; }
    10811081    size_t                           TypeCount(void) { return mEventTypes.size(); }
    10821082
     
    11401140     *  for HGCM (VMMDev) communication. */
    11411141    Console                 *mConsole;
    1142     /** The next upcoming context ID for this object. */
     1142    /**  The next context ID counter component for this object. */
    11431143    uint32_t                 mNextContextID;
    11441144    /** Local listener for handling the waiting events
  • trunk/src/VBox/Main/include/GuestSessionImpl.h

    r75798 r75861  
    2929#include "GuestSessionImplTasks.h"
    3030
     31#include <iprt/asm.h> /** @todo r=bird: Needed for ASMBitSet() in GuestSession::Data constructor.  Removed when
     32                       *        that is moved into the class implementation file as it should be. */
    3133#include <deque>
    3234
     
    3638 * Guest session implementation.
    3739 */
    38 class ATL_NO_VTABLE GuestSession :
    39     public GuestSessionWrap,
    40     public GuestBase
     40class ATL_NO_VTABLE GuestSession
     41    : public GuestSessionWrap
     42    , public GuestBase
    4143{
    4244public:
     
    245247    struct SessionObject
    246248    {
    247         /** Creation timestamp (in ms). */
    248         uint64_t          tsCreatedMs;
     249        /** Creation timestamp (in ms).
     250         * @note not used by anyone at the moment.  */
     251        uint64_t          msBirth;
    249252        /** The object type. */
    250253        SESSIONOBJECTTYPE enmType;
     
    305308    Guest                  *i_getParent(void) { return mParent; }
    306309    uint32_t                i_getProtocolVersion(void) { return mData.mProtocolVersion; }
    307     int                     i_objectRegister(SESSIONOBJECTTYPE enmType, uint32_t *puObjectID);
    308     int                     i_objectRegisterEx(SESSIONOBJECTTYPE enmType, uint32_t fFlags, uint32_t *puObjectID);
     310    int                     i_objectRegister(SESSIONOBJECTTYPE enmType, uint32_t *pidObject);
    309311    int                     i_objectUnregister(uint32_t uObjectID);
    310312    int                     i_pathRename(const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags, int *pGuestRc);
     
    341343    const ComObjPtr<EventSource>    mEventSource;
    342344
     345    /** @todo r=bird: One of the core points of the DATA sub-structures in Main is
     346     * hinding implementation details and stuff that requires including iprt/asm.h.
     347     * The way it's used here totally defeats that purpose.  You need to make it
     348     * a pointer to a anynmous Data struct and define that structure in
     349     * GuestSessionImpl.cpp and allocate it in the Init() function.
     350     */
    343351    struct Data
    344352    {
     
    367375        /** Map of registered session objects (files, directories, ...). */
    368376        SessionObjects              mObjects;
    369         /** Queue of object IDs which are not used anymore (free list).
    370          *  Acts as a "free list" for the mObjects map. */
    371         SessionObjectsFree          mObjectsFree;
    372377        /** Guest control protocol version to be used.
    373378         *  Guest Additions < VBox 4.3 have version 1,
     
    379384         *  returned from the guest side. */
    380385        int                         mRC;
     386        /** Object ID allocation bitmap; clear bits are free, set bits are busy. */
     387        uint64_t                    bmObjectIds[VBOX_GUESTCTRL_MAX_OBJECTS / sizeof(uint64_t) / 8];
    381388
    382389        Data(void)
    383390            : mpBaseEnvironment(NULL)
    384         { }
     391        {
     392            RT_ZERO(bmObjectIds);
     393            ASMBitSet(&bmObjectIds, VBOX_GUESTCTRL_MAX_OBJECTS - 1);    /* Reserved for the session itself? */
     394            ASMBitSet(&bmObjectIds, 0);                                 /* Let's reserve this too. */
     395        }
    385396        Data(const Data &rThat)
    386397            : mCredentials(rThat.mCredentials)
     
    393404            , mProcesses(rThat.mProcesses)
    394405            , mObjects(rThat.mObjects)
    395             , mObjectsFree(rThat.mObjectsFree)
    396406            , mProtocolVersion(rThat.mProtocolVersion)
    397407            , mTimeout(rThat.mTimeout)
    398408            , mRC(rThat.mRC)
    399         { }
     409        {
     410            memcpy(&bmObjectIds, &rThat.bmObjectIds, sizeof(bmObjectIds));
     411        }
    400412        ~Data(void)
    401413        {
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette