STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ppltaskscheduler.h
Go to the documentation of this file.
1 /***
2 * ==++==
3 *
4 * Copyright (c) Microsoft Corporation. All rights reserved.
5 *
6 * ==--==
7 * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
8 *
9 * ppltaskscheduler.h
10 *
11 * Parallel Patterns Library - Internal threadpool
12 *
13 * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
14 ****/
15 
16 #pragma once
17 
18 #include <crtdefs.h>
19 
20 #pragma pack(push,_CRT_PACKING)
21 #pragma warning(push,3)
22 
23 namespace Concurrency { namespace details {
24  typedef void(__cdecl *_Threadpool_callback)(void*);
25 
27  {
28  void *_M_work; // Windows::System::Threading::WorkItemHandler^ or PTP_M_work
30  void *_M_data;
31 
32  _Threadpool_chore(_Threadpool_callback _Callback, void *_Data) : _M_work(nullptr), _M_callback(_Callback), _M_data(_Data) {}
33  _Threadpool_chore() : _M_work(nullptr), _M_callback(nullptr), _M_data(nullptr) {}
34  };
35 
36  _CRTIMP2 int __cdecl _Schedule_chore(_Threadpool_chore*);
37  _CRTIMP2 void __cdecl _Release_chore(_Threadpool_chore*);
38  _CRTIMP2 int __cdecl _Reschedule_chore(const _Threadpool_chore*);
39 
40 
42  {
44 
45  static void __cdecl _Callback(void *_TpTask)
46  {
47  static_cast<_Threadpool_task*>(_TpTask)->_Invoke();
48  }
49 
50  public:
51 
52  _Threadpool_task(): _M_chore{&_Callback, this} {}
53 
54  virtual void _Invoke() throw() = 0;
55 
56  virtual ~_Threadpool_task()
57  {
58  _Release_chore(&_M_chore);
59  }
60 
61  void _Schedule()
62  {
63  _Schedule_chore(&_M_chore);
64  }
65 
66  void _Reschedule() const
67  {
68  _Reschedule_chore(&_M_chore);
69  }
70 
71  bool _Is_scheduled() const throw()
72  {
73  return _M_chore._M_work != nullptr;
74  }
75  };
76 } }
77 
78 #pragma warning(pop)
79 #pragma pack(pop)
_Threadpool_callback _M_callback
Definition: ppltaskscheduler.h:29
_CRTIMP2 int __cdecl _Reschedule_chore(const _Threadpool_chore *)
_CRTIMP2 void __cdecl _Release_chore(_Threadpool_chore *)
static void __cdecl _Callback(void *_TpTask)
Definition: ppltaskscheduler.h:45
bool _Is_scheduled() const
Definition: ppltaskscheduler.h:71
The Concurrency namespace provides classes and functions that provide access to the Concurrency Runti...
Definition: agents.h:43
void * _M_work
Definition: ppltaskscheduler.h:28
_CRTIMP2 int __cdecl _Schedule_chore(_Threadpool_chore *)
Definition: ppltaskscheduler.h:26
_Threadpool_chore(_Threadpool_callback _Callback, void *_Data)
Definition: ppltaskscheduler.h:32
_Threadpool_chore()
Definition: ppltaskscheduler.h:33
_Threadpool_task()
Definition: ppltaskscheduler.h:52
void _Schedule()
Definition: ppltaskscheduler.h:61
#define _CRTIMP2
Definition: crtdefs.h:36
void _Reschedule() const
Definition: ppltaskscheduler.h:66
_CRT_BEGIN_C_HEADER typedef void(__CRTDECL *unexpected_handler)()
Definition: ppltaskscheduler.h:41
void * _M_data
Definition: ppltaskscheduler.h:30
_Threadpool_chore _M_chore
Definition: ppltaskscheduler.h:43
void(__cdecl * _Threadpool_callback)(void *)
Definition: ppltaskscheduler.h:24