OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 BASE_SHARED_MEMORY_H_ | 5 #ifndef BASE_SHARED_MEMORY_H_ |
6 #define BASE_SHARED_MEMORY_H_ | 6 #define BASE_SHARED_MEMORY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // locked by the same thread. | 166 // locked by the same thread. |
167 // TODO(port): | 167 // TODO(port): |
168 // WARNING: on POSIX the lock only works across processes, not | 168 // WARNING: on POSIX the lock only works across processes, not |
169 // across threads. 2 threads in the same process can both grab the | 169 // across threads. 2 threads in the same process can both grab the |
170 // lock at the same time. There are several solutions for this | 170 // lock at the same time. There are several solutions for this |
171 // (futex, lockf+anon_semaphore) but none are both clean and common | 171 // (futex, lockf+anon_semaphore) but none are both clean and common |
172 // across Mac and Linux. | 172 // across Mac and Linux. |
173 void Lock(); | 173 void Lock(); |
174 | 174 |
175 #if defined(OS_WIN) | 175 #if defined(OS_WIN) |
176 // A Lock() implementation with a timeout. Returns true if the Lock() has | 176 // A Lock() implementation with a timeout that also allows setting |
177 // been acquired, false if the timeout was reached. | 177 // security attributes on the mutex. sec_attr may be NULL. |
178 bool Lock(uint32 timeout_ms); | 178 // Returns true if the Lock() has been acquired, false if the timeout was |
| 179 // reached. |
| 180 bool Lock(uint32 timeout_ms, SECURITY_ATTRIBUTES* sec_attr); |
179 #endif | 181 #endif |
180 | 182 |
181 // Releases the shared memory lock. | 183 // Releases the shared memory lock. |
182 void Unlock(); | 184 void Unlock(); |
183 | 185 |
184 private: | 186 private: |
185 #if defined(OS_POSIX) | 187 #if defined(OS_POSIX) |
186 bool PrepareMapFile(FILE *fp); | 188 bool PrepareMapFile(FILE *fp); |
187 bool FilePathForMemoryName(const std::string& mem_name, FilePath* path); | 189 bool FilePathForMemoryName(const std::string& mem_name, FilePath* path); |
188 void LockOrUnlockCommon(int function); | 190 void LockOrUnlockCommon(int function); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 } | 225 } |
224 | 226 |
225 private: | 227 private: |
226 SharedMemory* shared_memory_; | 228 SharedMemory* shared_memory_; |
227 DISALLOW_COPY_AND_ASSIGN(SharedMemoryAutoLock); | 229 DISALLOW_COPY_AND_ASSIGN(SharedMemoryAutoLock); |
228 }; | 230 }; |
229 | 231 |
230 } // namespace base | 232 } // namespace base |
231 | 233 |
232 #endif // BASE_SHARED_MEMORY_H_ | 234 #endif // BASE_SHARED_MEMORY_H_ |
OLD | NEW |