Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
880 B

  1. //
  2. // refcount.inl
  3. //
  4. // This file implements the member functions of
  5. // CRefCount as defined in smartptr.h.
  6. // Refer to smartptr.h for all information.
  7. //
  8. //-------------------------------------------
  9. //
  10. // Initialize the reference count to -1. We Use -1 so
  11. // that it will be possible to determine when the first reference
  12. // is made.
  13. //
  14. inline
  15. CRefCount::CRefCount( ) : m_refs( -1 ) { }
  16. //-------------------------------------------
  17. inline LONG
  18. CRefCount::AddRef( ) {
  19. //
  20. // Add a reference to an object.
  21. //
  22. return InterlockedIncrement( &m_refs ) ;
  23. }
  24. //-------------------------------------------
  25. inline LONG
  26. CRefCount::RemoveRef( ) {
  27. //
  28. // Remove a Reference from an object.
  29. // When this function returns a negative number the object
  30. // should be destroyed.
  31. //
  32. return InterlockedDecrement( &m_refs ) ;
  33. }