IThreadUtil.h#

Fully qualified name: carb/thread/IThreadUtil.h

File members: carb/thread/IThreadUtil.h

// SPDX-FileCopyrightText: Copyright (c) 2020-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
//
// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
// property and proprietary rights in and to this material, related
// documentation and any modifications thereto. Any use, reproduction,
// disclosure or distribution of this material and related documentation
// without an express license agreement from NVIDIA CORPORATION or
// its affiliates is strictly prohibited.
#pragma once

#include "../Interface.h"

namespace carb
{
namespace thread
{

using RelayFlags = uint64_t;

constexpr RelayFlags fRelayFlagBlocking = 0x8000000000000000ull;

constexpr RelayFlags fRelayFlagForce = 0x4000000000000000ull;

constexpr RelayFlags fRelayAvailableFlagsMask = 0x0000ffffffffffffull;

using RelayTaskFn = void(CARB_ABI*)(RelayFlags flags, void* context);

struct RelayTaskDesc
{
    RelayTaskFn task;

    RelayFlags flags;

    void* context;
};

enum class RelayResult
{
    eSuccess,

    eBadParam,

    eThreadFailure,

    eShutdown,

    eForced,

    eNoMemory,
};

struct IThreadUtil
{
    CARB_PLUGIN_INTERFACE("carb::thread::IThreadUtil", 1, 0)

    RelayResult(CARB_ABI* runRelayTask)(RelayTaskDesc& desc);
};

} // namespace thread
} // namespace carb