Ref counting
[iotcloud.git] / version2 / src / C / CommitPart.h
index 8c8e926ac260eaf23a39efb70c502d9512667587..7b8be2e8450c76c67a8aa096be23680b73e57706 100644 (file)
@@ -15,6 +15,7 @@ private:
        int64_t transactionSequenceNumber;
        int32_t partNumber;     // Parts position in the
        bool fldisLastPart;
+       int32_t refCount;
        Array<char> *data;
 
        Pair<int64_t, int32_t> partId;
@@ -24,11 +25,10 @@ public:
        CommitPart(Slot *s, int64_t _machineId, int64_t _sequenceNumber, int64_t _transactionSequenceNumber, int _partNumber, Array<char> *_data, bool _isLastPart);
        ~CommitPart();
        int getSize();
-       void setSlot(Slot *s);
        int getPartNumber();
        int getDataSize();
        Array<char> *getData();
-       Pair<int64_t, int32_t> getPartId();
+       Pair<int64_t, int32_t> getPartId();
        Pair<int64_t, int64_t> getCommitId();
        bool isLastPart();
        int64_t getMachineId();
@@ -37,6 +37,8 @@ public:
        void encode(ByteBuffer *bb);
        char getType();
        Entry *getCopy(Slot *s);
+       void releaseRef() {if ((--refCount)==0) delete this;}   
+       void acquireRef() {refCount++;}
 };
 
 Entry *CommitPart_decode(Slot *s, ByteBuffer *bb);