다음을 통해 공유


IHttpUser::ReferenceUser 메서드

사용자 내부 참조 수를 증분합니다.

구문

virtual VOID ReferenceUser(  
   VOID  
) = 0;  

매개 변수

이 메서드는 매개 변수를 사용하지 않습니다.

스레드 보안

IHttpUser 인터페이스를 구현하는 클래스는 및 DereferenceUser 메서드에 대해 ReferenceUser 스레드로부터 안전합니다.

설명

인터페이스를 구현 IHttpUser 하는 클래스는 메모리 관리에 안전한 스레드인 참조 계산을 사용합니다. 포인터가 IHttpUser 생성되면 내부 참조 수( private 멤버 변수)가 1로 설정됩니다. 메서드가 ReferenceUser 호출되면 이 참조 수가 1씩 증가합니다. 메서드가 DereferenceUser 호출되면 이 동일한 참조 수가 1씩 감소합니다. 인터페이스는 IHttpUser 참조 수가 0으로 이동한 경우에만 힙에서 제거됩니다. 이 체계는 해당 포인터의 마지막 클라이언트가 메서드를 IHttpUser 호출할 때까지 포인터가 삭제되지 않도록 보장합니다 DereferenceUser .

구현자에 대한 참고 사항

DereferenceUser 메서드 구현은 ReferenceUser 포인터에 대해 스레드로부터 IHttpUser 안전해야 합니다. 구현자는 참조 수가 0으로 전환되는 경우에만 호출되는 또는 protected 소멸자만 private 제공해야 합니다.

호출자 참고 사항

클라이언트는 인터페이스를 IHttpUser 더 특정 클래스로 캐스팅한 다음 직접 호출 delete 하려고 시도해서는 안 됩니다. 클라이언트는 인터페이스에 대한 포인터를 검색할 때 메서드를 IHttpUser 정확히 한 번 호출 ReferenceUser 한 다음 인터페이스에 더 이상 액세스하지 않을 때 IHttpUser 메서드를 호출 DereferenceUser 해야 합니다. 포인터가 ReferenceUserDereferenceUser 더 이상 필요하지 않을 때 액세스하고 삭제할 때 포인터가 IHttpUser 힙에서 유효하도록 보장하기 위해 및 메서드를 각각 가능한 한 일찍 및 늦게 호출해야 합니다.

예제

다음 코드 예제에서는 라는 클래스 MyHttpUser 를 구현 하는 인터페이스입니다 IHttpUser .

// Create a class that implements the IHttpUser interface.  
class MyHttpUser : public IHttpUser  
{  
public:  
    // Create a public constructor.  
    // Set the internal reference count to 1.  
    MyHttpUser()  
    {  
        m_cRefs = 1;  
    }  
  
    // Increment the internal reference count.  
    virtual VOID ReferenceUser(VOID)  
    {  
        InterlockedIncrement(&m_cRefs);  
    }  
  
    // Decrement the internal reference count.  
    virtual VOID DereferenceUser(VOID)  
    {  
        // Decrement the reference count and call delete this  
        // if the count is 0.  
        if (0 == InterlockedDecrement(&m_cRefs))  
        {  
            delete this;  
        }  
    }  
  
private:  
    // Create a private destructor called from DereferenceUser.  
    virtual ~MyHttpUser()  
    {  
  
    }  
  
    // Create a private reference count member.  
    LONG m_cRefs;  
}  

요구 사항

형식 Description
클라이언트 - Windows Vista의 IIS 7.0
- Windows 7의 IIS 7.5
- Windows 8의 IIS 8.0
- WINDOWS 10 IIS 10.0
서버 - Windows Server 2008의 IIS 7.0
- Windows Server 2008 R2의 IIS 7.5
- Windows Server 2012의 IIS 8.0
- Windows Server 2012 R2의 IIS 8.5
- WINDOWS SERVER 2016 IIS 10.0
제품 - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
- IIS Express 7.5, IIS Express 8.0, IIS Express 10.0
헤더 Httpserv.h

참고 항목

IHttpUser 인터페이스