LCOV - code coverage report
Current view: top level - include/hpactor/mem - hibernatable.hpp (source / functions) Coverage Total Hit
Test: HPActor Coverage Lines: 100.0 % 1 1
Test Date: 2026-05-20 02:24:49 Functions: 50.0 % 2 1
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: - 0 0

             Branch data     Line data    Source code
       1                 :             : // Copyright 2026 HPActor Contributors
       2                 :             : //
       3                 :             : // Licensed under the Apache License, Version 2.0 (the "License");
       4                 :             : // you may not use this file except in compliance with the License.
       5                 :             : // You may obtain a copy of the License at
       6                 :             : //
       7                 :             : //     http://www.apache.org/licenses/LICENSE-2.0
       8                 :             : //
       9                 :             : // Unless required by applicable law or agreed to in writing, software
      10                 :             : // distributed under the License is distributed on an "AS IS" BASIS,
      11                 :             : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12                 :             : // See the License for the specific language governing permissions and
      13                 :             : // limitations under the License.
      14                 :             : 
      15                 :             : #pragma once
      16                 :             : 
      17                 :             : #include <cstddef>
      18                 :             : #include <span>
      19                 :             : 
      20                 :             : namespace hpactor::mem {
      21                 :             : 
      22                 :             : // Interface for actors that support hibernation.
      23                 :             : // Actors implementing this can be serialized to a compact buffer,
      24                 :             : // released from hot memory, and later deserialized back.
      25                 :             : class Hibernatable {
      26                 :             :   public:
      27                 :           1 :     virtual ~Hibernatable() = default;
      28                 :             : 
      29                 :             :     // Return the serialized size of this actor's state.
      30                 :             :     // Must be constant for the actor's lifetime.
      31                 :             :     virtual size_t serialized_size() const = 0;
      32                 :             : 
      33                 :             :     // Serialize actor state into the provided buffer.
      34                 :             :     // Buffer is guaranteed to be at least serialized_size() bytes.
      35                 :             :     virtual void serialize_to(std::span<std::byte> buffer) const = 0;
      36                 :             : 
      37                 :             :     // Deserialize actor state from the provided buffer.
      38                 :             :     // Called after the actor's hot memory has been allocated.
      39                 :             :     virtual void deserialize_from(std::span<const std::byte> buffer) = 0;
      40                 :             : };
      41                 :             : 
      42                 :             : } // namespace hpactor::mem
        

Generated by: LCOV version 2.0-1