1/*
2 * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3 *
4 * NVIDIA CORPORATION and its licensors retain all intellectual property
5 * and proprietary rights in and to this software, related documentation
6 * and any modifications thereto. Any use, reproduction, disclosure or
7 * distribution of this software and related documentation without an express
8 * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 */
10
11#ifndef PX_CPU_DISPATCHER_H
12#define PX_CPU_DISPATCHER_H
13
14#include "foundation/Px.h"
15
16#ifndef PX_DOXYGEN
17namespace physx
18{
19#endif
20
21class PxBaseTask;
22
23/**
24 \brief A CpuDispatcher is responsible for scheduling the execution of tasks passed to it by the SDK.
25
26 A typical implementation would for example use a thread pool with the dispatcher
27 pushing tasks onto worker thread queues or a global queue.
28
29 @see PxBaseTask
30 @see PxTask
31 @see PxTaskManager
32*/
33class PxCpuDispatcher
34{
35public:
36 /**
37 \brief Called by the TaskManager when a task is to be queued for execution.
38
39 Upon receiving a task, the dispatcher should schedule the task
40 to run when resource is available. After the task has been run,
41 it should call the release() method and discard it's pointer.
42
43 \param[in] task The task to be run.
44
45 @see PxBaseTask
46 */
47 virtual void submitTask( PxBaseTask& task ) = 0;
48
49 /**
50 \brief Returns the number of available worker threads for this dispatcher.
51
52 The SDK will use this count to control how many tasks are submitted. By
53 matching the number of tasks with the number of execution units task
54 overhead can be reduced.
55 */
56 virtual PxU32 getWorkerCount() const = 0;
57
58 virtual ~PxCpuDispatcher() {}
59};
60
61#ifndef PX_DOXYGEN
62} // end physx namespace
63#endif
64
65#endif
66