Updated refcount.cpp to a newer coding convention.

This commit is contained in:
Jonas 'Sortie' Termansen 2012-07-22 21:25:36 +02:00
parent 3907e14cb8
commit 8c5ab54c9b
2 changed files with 41 additions and 40 deletions

View File

@ -1,6 +1,6 @@
/*******************************************************************************
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2012.
Copyright(C) Jonas 'Sortie' Termansen 2012.
This file is part of Sortix.
@ -25,24 +25,24 @@
#ifndef SORTIX_REFCOUNT_H
#define SORTIX_REFCOUNT_H
namespace Sortix
namespace Sortix {
class Refcounted
{
class Refcounted
{
public:
Refcounted();
~Refcounted();
public:
Refcounted();
~Refcounted();
public:
void Refer();
void Unref();
inline size_t Refcount() const { return refcount; }
public:
void Refer();
void Unref();
inline size_t Refcount() const { return refcount; }
private:
size_t refcount;
private:
size_t refcount;
};
}
};
} // namespace Sortix
#endif

View File

@ -1,6 +1,6 @@
/*******************************************************************************
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2012.
Copyright(C) Jonas 'Sortie' Termansen 2012.
This file is part of Sortix.
@ -23,30 +23,31 @@
*******************************************************************************/
#include <sortix/kernel/platform.h>
#include "refcount.h"
#include <sortix/kernel/refcount.h>
namespace Sortix
namespace Sortix {
Refcounted::Refcounted()
{
Refcounted::Refcounted()
{
refcount = 1;
}
Refcounted::~Refcounted()
{
// It's OK to be deleted if our refcount is 1, it won't mess with any
// other owners that might need us.
ASSERT(refcount <= 1);
}
void Refcounted::Refer()
{
refcount++;
}
void Refcounted::Unref()
{
if ( !--refcount ) { delete this; }
}
refcount = 1;
}
Refcounted::~Refcounted()
{
// It's OK to be deleted if our refcount is 1, it won't mess with any
// other owners that might need us.
ASSERT(refcount <= 1);
}
void Refcounted::Refer()
{
refcount++;
}
void Refcounted::Unref()
{
if ( !--refcount )
delete this;
}
} // namespace Sortix