CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
task_scheduler.h
1
2#pragma once
3
4#include <system/object.h>
5#include <functional>
6
7namespace System { namespace Threading { namespace Tasks {
8
10class ASPOSECPP_SHARED_CLASS TaskScheduler : public Object
11{
12 using ThisType = TaskScheduler;
13
14public:
17 static ASPOSECPP_SHARED_API const SharedPtr<TaskScheduler>& get_Default();
20 static ASPOSECPP_SHARED_API SharedPtr<TaskScheduler> get_Current();
23 virtual ASPOSECPP_SHARED_API int32_t get_MaximumConcurrencyLevel() const;
26 int32_t get_Id() const {return m_id;}
27
31
32protected:
34
35 friend Task;
36
37 ASPOSECPP_SHARED_API bool TryExecuteTask(const SharedPtr<Task>&);
38 virtual ASPOSECPP_SHARED_API bool TryExecuteTaskInline(const SharedPtr<Task>&, bool taskWasPreviouslyQueued) = 0;
39 virtual ASPOSECPP_SHARED_API void QueueTask(const SharedPtr<Task>&) = 0;
40 virtual ASPOSECPP_SHARED_API bool TryDequeue(const SharedPtr<Task>&);
41
42 int32_t m_id;
43
44 static int32_t m_next_id;
45 static thread_local Task* m_current_task;
46};
47
49ASPOSECPP_SHARED_API void DispatchCurrentContext();
50
51}}} // namespace System::Threading::Tasks
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
Represents an asynchronous operation that can be awaited and composed with other tasks.
Definition: task.h:27
Represents an object that handles the low-level work of queuing tasks onto threads.
Definition: task_scheduler.h:11
virtual int32_t get_MaximumConcurrencyLevel() const
Indicates the maximum concurrency level this TaskScheduler is able to support.
virtual void QueueTask(const SharedPtr< Task > &)=0
bool TryExecuteTask(const SharedPtr< Task > &)
virtual bool TryExecuteTaskInline(const SharedPtr< Task > &, bool taskWasPreviouslyQueued)=0
static int32_t m_next_id
Definition: task_scheduler.h:44
static thread_local Task * m_current_task
Definition: task_scheduler.h:45
static const SharedPtr< TaskScheduler > & get_Default()
Gets the default TaskScheduler instance that is provided by the framework.
static SharedPtr< TaskScheduler > get_Current()
Gets the TaskScheduler associated with the currently executing task.
friend Task
Definition: task_scheduler.h:35
static SharedPtr< TaskScheduler > FromCurrentSynchronizationContext()
Creates a TaskScheduler associated with the current thread.
int32_t get_Id() const
Gets the unique ID for this TaskScheduler.
Definition: task_scheduler.h:26
int32_t m_id
Definition: task_scheduler.h:42
virtual bool TryDequeue(const SharedPtr< Task > &)
void DispatchCurrentContext()
Dispatches all tasks bound to this thread synchronously.
Definition: db_command.h:9