IThreadPool.h#

Fully qualified name: carb/tasking/IThreadPool.h

File members: carb/tasking/IThreadPool.h

// SPDX-FileCopyrightText: Copyright (c) 2019-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 tasking
{

class ThreadPool DOXYGEN_EMPTY_CLASS;

typedef void (*JobFn)(void* jobData);

struct IThreadPool
{
    CARB_PLUGIN_INTERFACE("carb::tasking::IThreadPool", 1, 0)

    ThreadPool*(CARB_ABI* createEx)(size_t workerCount);

    ThreadPool* create() const;

    void(CARB_ABI* destroy)(ThreadPool* threadPool);

    size_t(CARB_ABI* getDefaultWorkerCount)();

    size_t(CARB_ABI* getWorkerCount)(ThreadPool* threadPool);

    bool(CARB_ABI* enqueueJob)(ThreadPool* threadPool, JobFn jobFunction, void* jobData);

    size_t(CARB_ABI* getCurrentlyRunningJobCount)(ThreadPool* threadPool);

    void(CARB_ABI* waitUntilFinished)(ThreadPool* threadPool);
};

inline ThreadPool* IThreadPool::create() const
{
    return createEx(getDefaultWorkerCount());
}

} // namespace tasking
} // namespace carb