]> git.sesse.net Git - casparcg/blob - concrt_extras/concrt_extras.h
(no commit message)
[casparcg] / concrt_extras / concrt_extras.h
1 //--------------------------------------------------------------------------\r
2 // \r
3 //  Copyright (c) Microsoft Corporation.  All rights reserved. \r
4 // \r
5 //  File: concrt_extras.h\r
6 //\r
7 //  Implementation of ConcRT helpers\r
8 //\r
9 //--------------------------------------------------------------------------\r
10 \r
11 #pragma once\r
12 \r
13 #include <concrtrm.h>\r
14 #include <concrt.h>\r
15 \r
16 namespace Concurrency\r
17 {\r
18     /// <summary>\r
19     /// An RAII style wrapper around Concurrency::Context::Oversubscribe,\r
20     /// useful for annotating known blocking calls\r
21     /// </summary>\r
22     class scoped_oversubcription_token\r
23     {\r
24     public:\r
25         scoped_oversubcription_token()\r
26         {\r
27             Concurrency::Context::CurrentContext()->Oversubscribe(true);\r
28         }\r
29         ~scoped_oversubcription_token()\r
30         {\r
31             Concurrency::Context::CurrentContext()->Oversubscribe(false);\r
32         }\r
33     };\r
34 }