Updated refcount.cpp to a newer coding convention.
This commit is contained in:
parent
3907e14cb8
commit
8c5ab54c9b
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2012.
|
Copyright(C) Jonas 'Sortie' Termansen 2012.
|
||||||
|
|
||||||
This file is part of Sortix.
|
This file is part of Sortix.
|
||||||
|
|
||||||
|
@ -25,24 +25,24 @@
|
||||||
#ifndef SORTIX_REFCOUNT_H
|
#ifndef SORTIX_REFCOUNT_H
|
||||||
#define SORTIX_REFCOUNT_H
|
#define SORTIX_REFCOUNT_H
|
||||||
|
|
||||||
namespace Sortix
|
namespace Sortix {
|
||||||
|
|
||||||
|
class Refcounted
|
||||||
{
|
{
|
||||||
class Refcounted
|
public:
|
||||||
{
|
|
||||||
public:
|
|
||||||
Refcounted();
|
Refcounted();
|
||||||
~Refcounted();
|
~Refcounted();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Refer();
|
void Refer();
|
||||||
void Unref();
|
void Unref();
|
||||||
inline size_t Refcount() const { return refcount; }
|
inline size_t Refcount() const { return refcount; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
size_t refcount;
|
size_t refcount;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
} // namespace Sortix
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2012.
|
Copyright(C) Jonas 'Sortie' Termansen 2012.
|
||||||
|
|
||||||
This file is part of Sortix.
|
This file is part of Sortix.
|
||||||
|
|
||||||
|
@ -23,30 +23,31 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <sortix/kernel/platform.h>
|
#include <sortix/kernel/platform.h>
|
||||||
#include "refcount.h"
|
#include <sortix/kernel/refcount.h>
|
||||||
|
|
||||||
namespace Sortix
|
namespace Sortix {
|
||||||
|
|
||||||
|
Refcounted::Refcounted()
|
||||||
{
|
{
|
||||||
Refcounted::Refcounted()
|
|
||||||
{
|
|
||||||
refcount = 1;
|
refcount = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Refcounted::~Refcounted()
|
Refcounted::~Refcounted()
|
||||||
{
|
{
|
||||||
// It's OK to be deleted if our refcount is 1, it won't mess with any
|
// It's OK to be deleted if our refcount is 1, it won't mess with any
|
||||||
// other owners that might need us.
|
// other owners that might need us.
|
||||||
ASSERT(refcount <= 1);
|
ASSERT(refcount <= 1);
|
||||||
}
|
|
||||||
|
|
||||||
void Refcounted::Refer()
|
|
||||||
{
|
|
||||||
refcount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Refcounted::Unref()
|
|
||||||
{
|
|
||||||
if ( !--refcount ) { delete this; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Refcounted::Refer()
|
||||||
|
{
|
||||||
|
refcount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Refcounted::Unref()
|
||||||
|
{
|
||||||
|
if ( !--refcount )
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Sortix
|
||||||
|
|
Loading…
Reference in New Issue