From ef1e2ab328087c61a6878c1e84f4fc5d710aebce Mon Sep 17 00:00:00 2001 From: dotnet-bot Date: Fri, 30 Jan 2015 14:14:42 -0800 Subject: Initial commit to populate CoreCLR repo [tfs-changeset: 1407945] --- src/binder/inc/loadcontext.inl | 91 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/binder/inc/loadcontext.inl (limited to 'src/binder/inc/loadcontext.inl') diff --git a/src/binder/inc/loadcontext.inl b/src/binder/inc/loadcontext.inl new file mode 100644 index 0000000000..b8002e03cc --- /dev/null +++ b/src/binder/inc/loadcontext.inl @@ -0,0 +1,91 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// +// ============================================================ +// +// LoadContext.inl +// + + +// +// Implements the inlined methods of LoadContext template class +// +// ============================================================ + +#ifndef __BINDER__LOAD_CONTEXT_INL__ +#define __BINDER__LOAD_CONTEXT_INL__ + +template +LoadContext::LoadContext() : + SHash >::SHash() +{ + m_cRef = 1; +} + +template +LoadContext::~LoadContext() +{ + // Delete context entries and contents array + for (typename Hash::Iterator i = Hash::Begin(), end = Hash::End(); i != end; i++) + { + const ContextEntry *pContextEntry = *i; + delete pContextEntry; + } + this->RemoveAll(); +} + +template +ULONG LoadContext::AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +template +ULONG LoadContext::Release() +{ + ULONG ulRef = InterlockedDecrement(&m_cRef); + + if (ulRef == 0) + { + delete this; + } + + return ulRef; +} + +template +ContextEntry *LoadContext::Lookup(AssemblyName *pAssemblyName) +{ + ContextEntry *pContextEntry = + SHash >::Lookup(pAssemblyName); + + return pContextEntry; +} + +template +HRESULT LoadContext::Register(BindResult *pBindResult) +{ + HRESULT hr = S_OK; + ContextEntry *pContextEntry = NULL; + + SAFE_NEW(pContextEntry, ContextEntry); + + pContextEntry->SetIsDynamicBind(pBindResult->GetIsDynamicBind()); + pContextEntry->SetIsInGAC(pBindResult->GetIsInGAC()); + pContextEntry->SetIsSharable(pBindResult->GetIsSharable()); + pContextEntry->SetAssemblyName(pBindResult->GetAssemblyName(), TRUE /* fAddRef */); + pContextEntry->SetAssembly(pBindResult->GetAssembly()); + + if (pBindResult->GetIsFirstRequest()) + { + pContextEntry->SetIsFirstRequest(TRUE); + } + + SHash >::Add(pContextEntry); + + Exit: + return hr; +} + +#endif -- cgit v1.2.3