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

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

Issue 10689170: Move the Windows sandbox to sandbox/win (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on top of tree (properly this time) Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « sandbox/src/unload_dll_test.cc ('k') | sandbox/src/win2k_threadpool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef SANDBOX_SRC_WIN2K_THREADPOOL_H_
6 #define SANDBOX_SRC_WIN2K_THREADPOOL_H_
7
8 #include <list>
9 #include <algorithm>
10 #include "sandbox/src/crosscall_server.h"
11
12 namespace sandbox {
13
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
16 // and requirements of this interface.
17 //
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
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
22 // arises.
23 //
24 // This implementation simply thunks to the nice thread pool API of win2k.
25 class Win2kThreadPool : public ThreadProvider {
26 public:
27 Win2kThreadPool() {
28 ::InitializeCriticalSection(&lock_);
29 }
30 virtual ~Win2kThreadPool();
31
32 virtual bool RegisterWait(const void* cookie, HANDLE waitable_object,
33 CrossCallIPCCallback callback,
34 void* context);
35
36 virtual bool UnRegisterWaits(void* cookie);
37
38 // Returns the total number of wait objects associated with
39 // the thread pool.
40 size_t OutstandingWaits();
41
42 private:
43 // record to keep track of a wait and its associated cookie.
44 struct PoolObject {
45 const void* cookie;
46 HANDLE wait;
47 };
48 // The list of pool wait objects.
49 typedef std::list<PoolObject> PoolObjects;
50 PoolObjects pool_objects_;
51 // This lock protects the list of pool wait objects.
52 CRITICAL_SECTION lock_;
53 DISALLOW_COPY_AND_ASSIGN(Win2kThreadPool);
54 };
55
56 } // namespace sandbox
57
58 #endif // SANDBOX_SRC_WIN2K_THREADPOOL_H_
OLDNEW
« no previous file with comments | « sandbox/src/unload_dll_test.cc ('k') | sandbox/src/win2k_threadpool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698