Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(951)

Side by Side Diff: sandbox/win/src/win2k_threadpool.h

Issue 1118473005: Apply automated fixits for Chrome clang plugin to sandbox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sandbox/win/src/target_services.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef SANDBOX_SRC_WIN2K_THREADPOOL_H_ 5 #ifndef SANDBOX_SRC_WIN2K_THREADPOOL_H_
6 #define SANDBOX_SRC_WIN2K_THREADPOOL_H_ 6 #define SANDBOX_SRC_WIN2K_THREADPOOL_H_
7 7
8 #include <list> 8 #include <list>
9 #include <algorithm> 9 #include <algorithm>
10 #include "sandbox/win/src/crosscall_server.h" 10 #include "sandbox/win/src/crosscall_server.h"
11 11
12 namespace sandbox { 12 namespace sandbox {
13 13
14 // Win2kThreadPool a simple implementation of a thread provider as required 14 // Win2kThreadPool a simple implementation of a thread provider as required
15 // for the sandbox IPC subsystem. See sandbox\crosscall_server.h for the details 15 // for the sandbox IPC subsystem. See sandbox\crosscall_server.h for the details
16 // and requirements of this interface. 16 // and requirements of this interface.
17 // 17 //
18 // Implementing the thread provider as a thread pool is desirable in the case 18 // Implementing the thread provider as a thread pool is desirable in the case
19 // of shared memory IPC because it can generate a large number of waitable 19 // of shared memory IPC because it can generate a large number of waitable
20 // events: as many as channels. A thread pool does not create a thread per 20 // events: as many as channels. A thread pool does not create a thread per
21 // event, instead maintains a few idle threads but can create more if the need 21 // event, instead maintains a few idle threads but can create more if the need
22 // arises. 22 // arises.
23 // 23 //
24 // This implementation simply thunks to the nice thread pool API of win2k. 24 // This implementation simply thunks to the nice thread pool API of win2k.
25 class Win2kThreadPool : public ThreadProvider { 25 class Win2kThreadPool : public ThreadProvider {
26 public: 26 public:
27 Win2kThreadPool(); 27 Win2kThreadPool();
28 virtual ~Win2kThreadPool(); 28 ~Win2kThreadPool() override;
29 29
30 virtual bool RegisterWait(const void* cookie, HANDLE waitable_object, 30 bool RegisterWait(const void* cookie,
31 CrossCallIPCCallback callback, 31 HANDLE waitable_object,
32 void* context); 32 CrossCallIPCCallback callback,
33 void* context) override;
33 34
34 virtual bool UnRegisterWaits(void* cookie); 35 bool UnRegisterWaits(void* cookie) override;
35 36
36 // Returns the total number of wait objects associated with 37 // Returns the total number of wait objects associated with
37 // the thread pool. 38 // the thread pool.
38 size_t OutstandingWaits(); 39 size_t OutstandingWaits();
39 40
40 private: 41 private:
41 // record to keep track of a wait and its associated cookie. 42 // record to keep track of a wait and its associated cookie.
42 struct PoolObject { 43 struct PoolObject {
43 const void* cookie; 44 const void* cookie;
44 HANDLE wait; 45 HANDLE wait;
45 }; 46 };
46 // The list of pool wait objects. 47 // The list of pool wait objects.
47 typedef std::list<PoolObject> PoolObjects; 48 typedef std::list<PoolObject> PoolObjects;
48 PoolObjects pool_objects_; 49 PoolObjects pool_objects_;
49 // This lock protects the list of pool wait objects. 50 // This lock protects the list of pool wait objects.
50 CRITICAL_SECTION lock_; 51 CRITICAL_SECTION lock_;
51 52
52 DISALLOW_COPY_AND_ASSIGN(Win2kThreadPool); 53 DISALLOW_COPY_AND_ASSIGN(Win2kThreadPool);
53 }; 54 };
54 55
55 } // namespace sandbox 56 } // namespace sandbox
56 57
57 #endif // SANDBOX_SRC_WIN2K_THREADPOOL_H_ 58 #endif // SANDBOX_SRC_WIN2K_THREADPOOL_H_
OLDNEW
« no previous file with comments | « sandbox/win/src/target_services.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698