aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/core/event.cpp
blob: 1c05ffc3fef7aab18619e8ed7aedd0a4c3564fb4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "event.h"
#include "event_pb.h" 
 
namespace NActors { 

    const TScopeId TScopeId::LocallyGenerated{
        Max<ui64>(), Max<ui64>()
    };

    TIntrusivePtr<TEventSerializedData> IEventHandle::ReleaseChainBuffer() {
        if (Buffer) {
            TIntrusivePtr<TEventSerializedData> result;
            DoSwap(result, Buffer);
            Event.Reset();
            return result;
        }
        if (Event) {
            TAllocChunkSerializer serializer;
            Event->SerializeToArcadiaStream(&serializer);
            auto chainBuf = serializer.Release(Event->IsExtendedFormat());
            Event.Reset();
            return chainBuf;
        }
        return new TEventSerializedData;
    } 
 
    TIntrusivePtr<TEventSerializedData> IEventHandle::GetChainBuffer() {
        if (Buffer)
            return Buffer;
        if (Event) {
            TAllocChunkSerializer serializer;
            Event->SerializeToArcadiaStream(&serializer);
            Buffer = serializer.Release(Event->IsExtendedFormat());
            return Buffer;
        }
        return new TEventSerializedData;
    } 
}