mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Fix bare assert in reference_counted_object.h (#613)
Signed-off-by: Ross Younger <crazyscot@gmail.com> Signed-off-by: Ross Younger <crazyscot@gmail.com>
This commit is contained in:
parent
daa42f2d4b
commit
92d8739db4
@ -98,5 +98,6 @@ SOFTWARE.
|
|||||||
#define ETL_BIT_STREAM_FILE_ID "65"
|
#define ETL_BIT_STREAM_FILE_ID "65"
|
||||||
#define ETL_BYTE_STREAM_FILE_ID "66"
|
#define ETL_BYTE_STREAM_FILE_ID "66"
|
||||||
#define ETL_BIP_BUFFER_SPSC_ATOMIC_FILE_ID "67"
|
#define ETL_BIP_BUFFER_SPSC_ATOMIC_FILE_ID "67"
|
||||||
|
#define ETL_REFERENCE_COUNTED_OBJECT_FILE_ID "68"
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -31,11 +31,39 @@
|
|||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include "atomic.h"
|
#include "atomic.h"
|
||||||
|
#include "error_handler.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
namespace etl
|
namespace etl
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
/// Exceptions for reference counting
|
||||||
|
///\ingroup reference_counting
|
||||||
|
//***************************************************************************
|
||||||
|
class reference_counting_exception : public etl::exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
reference_counting_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
|
||||||
|
: exception(reason_, file_name_, line_number_)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//***************************************************************************
|
||||||
|
/// Reference counter overrun exception
|
||||||
|
///\ingroup reference_counting
|
||||||
|
//***************************************************************************
|
||||||
|
class reference_count_overrun : public etl::reference_counting_exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
reference_count_overrun(string_type file_name_, numeric_type line_number_)
|
||||||
|
: etl::reference_counting_exception(ETL_ERROR_TEXT("reference_counting:overrun", ETL_REFERENCE_COUNTED_OBJECT_FILE_ID"A"), file_name_, line_number_)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
/// The base of all reference counters.
|
/// The base of all reference counters.
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
@ -87,7 +115,7 @@ namespace etl
|
|||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
ETL_NODISCARD virtual int32_t decrement_reference_count() ETL_OVERRIDE
|
ETL_NODISCARD virtual int32_t decrement_reference_count() ETL_OVERRIDE
|
||||||
{
|
{
|
||||||
assert(reference_count > 0);
|
ETL_ASSERT(reference_count > 0, ETL_ERROR(reference_count_overrun));
|
||||||
|
|
||||||
return int32_t(--reference_count);
|
return int32_t(--reference_count);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user