Skip to content

Conversation

@oldnewthing
Copy link
Member

If the source contributes to the module object count, then the weak reference also contributes, so that we do not unload prematurely.

Factored out module lock updating into helper base class module_lock_updater with specialization update_module_lock. This avoids a lot of code duplication.

If the source contributes to the module object count,
then the weak reference also contributes,
so that we do not unload prematurely.

Factored out module lock updating into helper base
class `module_lock_updater` with specialization
`update_module_lock`.
@oldnewthing
Copy link
Member Author

Wondering why weak_source_producer was defined as

    template <bool Agile>
    struct weak_source_producer
    {
    protected:
        weak_source<Agile> m_source;
    };

instead of

    template <bool Agile>
    struct weak_source_producer : protected weak_source<Agile>
    {
    };

This alternate definition would greatly simplify weak_ref::that():

        weak_ref<Agile>* that() noexcept
        {
            return static_cast<weak_ref<Agile>*>(this);
        }

@kennykerr
Copy link
Collaborator

@oldnewthing no particular reason - feel free to fix.

@oldnewthing
Copy link
Member Author

oldnewthing commented Apr 21, 2020

Oh, it's because weak_source is final because it wants to have a different QI from its parent object.

@kennykerr
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

Copy link
Collaborator

@kennykerr kennykerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kennykerr kennykerr merged commit 91accec into microsoft:master Apr 21, 2020
@oldnewthing oldnewthing deleted the weak_refcount branch April 21, 2020 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants