aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/interconnect/packet.cpp
blob: 7b0bdf3e1724833babc0d9a5b2ada1bd5aa40304 (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
39
40
41
42
#include "packet.h"

#include <library/cpp/actors/core/probes.h>

#include <util/system/datetime.h>

LWTRACE_USING(ACTORLIB_PROVIDER);

ui32 TEventHolder::Fill(IEventHandle& ev) {
    Serial = 0;
    Descr.Type = ev.Type;
    Descr.Flags = ev.Flags;
    Descr.Recipient = ev.Recipient;
    Descr.Sender = ev.Sender;
    Descr.Cookie = ev.Cookie;
    ForwardRecipient = ev.GetForwardOnNondeliveryRecipient();
    EventActuallySerialized = 0;
    Descr.Checksum = 0;

    if (ev.IsEventLight()) {
        if (ev.IsEventSerializable()) {
            NActors::IEventHandleLightSerializable& serializable(*NActors::IEventHandleLightSerializable::GetLightSerializable(&ev));
            EventSerializer = serializable.Serializer;
            EventSerializedSize = 100;
        } else {
            EventSerializedSize = 0;
        }
    } else {
        auto& evFat = *IEventHandleFat::GetFat(&ev);
        if (evFat.HasBuffer()) {
            Buffer = evFat.ReleaseChainBuffer();
            EventSerializedSize = Buffer->GetSize();
        } else if (evFat.HasEvent()) {
            Event.Reset(evFat.ReleaseBase());
            EventSerializedSize = Event->CalculateSerializedSize();
        } else {
            EventSerializedSize = 0;
        }
    }

    return EventSerializedSize;
}