Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/ETLCPP/etl into deve…
Browse files Browse the repository at this point in the history
…lopment
  • Loading branch information
jwellbelove committed Oct 2, 2022
2 parents c8471e5 + 7bf7a4d commit 74b3cad
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/etl/file_error_numbers.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,6 @@ SOFTWARE.
#define ETL_BIT_STREAM_FILE_ID "65"
#define ETL_BYTE_STREAM_FILE_ID "66"
#define ETL_BIP_BUFFER_SPSC_ATOMIC_FILE_ID "67"
#define ETL_REFERENCE_COUNTED_OBJECT_FILE_ID "68"

#endif
30 changes: 29 additions & 1 deletion include/etl/reference_counted_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,39 @@

#include "platform.h"
#include "atomic.h"
#include "error_handler.h"

#include <stdint.h>

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.
//***************************************************************************
Expand Down Expand Up @@ -87,7 +115,7 @@ namespace etl
//***************************************************************************
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);
}
Expand Down

0 comments on commit 74b3cad

Please sign in to comment.