| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 #ifndef Locker_h | 28 #ifndef Locker_h |
| 29 #define Locker_h | 29 #define Locker_h |
| 30 | 30 |
| 31 #include "wtf/Allocator.h" | 31 #include "wtf/Allocator.h" |
| 32 #include "wtf/Noncopyable.h" | 32 #include "wtf/Noncopyable.h" |
| 33 | 33 |
| 34 namespace WTF { | 34 namespace WTF { |
| 35 | 35 |
| 36 template <typename T> class Locker final { | 36 template <typename T> |
| 37 STACK_ALLOCATED(); | 37 class Locker final { |
| 38 WTF_MAKE_NONCOPYABLE(Locker); | 38 STACK_ALLOCATED(); |
| 39 public: | 39 WTF_MAKE_NONCOPYABLE(Locker); |
| 40 Locker(T& lockable) : m_lockable(lockable) { m_lockable.lock(); } | 40 |
| 41 ~Locker() { m_lockable.unlock(); } | 41 public: |
| 42 private: | 42 Locker(T& lockable) : m_lockable(lockable) { m_lockable.lock(); } |
| 43 T& m_lockable; | 43 ~Locker() { m_lockable.unlock(); } |
| 44 |
| 45 private: |
| 46 T& m_lockable; |
| 44 }; | 47 }; |
| 45 | |
| 46 } | 48 } |
| 47 | 49 |
| 48 using WTF::Locker; | 50 using WTF::Locker; |
| 49 | 51 |
| 50 #endif | 52 #endif |
| OLD | NEW |