Program Listing for File fence.hpp

Return to documentation for file (inexor/vulkan-renderer/wrapper/fence.hpp)

#pragma once

#include <volk.h>

#include <cstdint>
#include <limits>
#include <string>

namespace inexor::vulkan_renderer::wrapper {

// Forward declaration
class Device;

class Fence {
    const Device &m_device;
    std::string m_name;
    VkFence m_fence{VK_NULL_HANDLE};

public:
    Fence(const Device &device, const std::string &name, bool in_signaled_state);

    Fence(const Fence &) = delete;
    Fence(Fence &&) noexcept;

    ~Fence();

    Fence &operator=(const Fence &) = delete;
    Fence &operator=(Fence &&) = delete;

    [[nodiscard]] VkFence get() const {
        return m_fence;
    }

    void block(std::uint64_t timeout_limit = std::numeric_limits<std::uint64_t>::max()) const;

    void reset() const;

    [[nodiscard]] VkResult status() const;
};

} // namespace inexor::vulkan_renderer::wrapper