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.
5 #ifndef SANDBOX_SRC_WIN2K_THREADPOOL_H_
6 #define SANDBOX_SRC_WIN2K_THREADPOOL_H_
10 #include "sandbox/win/src/crosscall_server.h"
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.
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
24 // This implementation simply thunks to the nice thread pool API of win2k.
25 class Win2kThreadPool
: public ThreadProvider
{
28 ~Win2kThreadPool() override
;
30 bool RegisterWait(const void* cookie
,
31 HANDLE waitable_object
,
32 CrossCallIPCCallback callback
,
33 void* context
) override
;
35 bool UnRegisterWaits(void* cookie
) override
;
37 // Returns the total number of wait objects associated with
39 size_t OutstandingWaits();
42 // record to keep track of a wait and its associated cookie.
47 // The list of pool wait objects.
48 typedef std::list
<PoolObject
> PoolObjects
;
49 PoolObjects pool_objects_
;
50 // This lock protects the list of pool wait objects.
51 CRITICAL_SECTION lock_
;
53 DISALLOW_COPY_AND_ASSIGN(Win2kThreadPool
);
56 } // namespace sandbox
58 #endif // SANDBOX_SRC_WIN2K_THREADPOOL_H_