OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 4760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4771 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 4771 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
4772 EXPECT_EQ(1u, map->size()); | 4772 EXPECT_EQ(1u, map->size()); |
4773 EXPECT_EQ(lifeObject, map->get(lifeObject)->link()); | 4773 EXPECT_EQ(lifeObject, map->get(lifeObject)->link()); |
4774 lifeObject.clear(); // Despite its name. | 4774 lifeObject.clear(); // Despite its name. |
4775 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); | 4775 Heap::collectGarbage(ThreadState::NoHeapPointersOnStack); |
4776 EXPECT_EQ(0u, map->size()); | 4776 EXPECT_EQ(0u, map->size()); |
4777 } | 4777 } |
4778 | 4778 |
4779 static Mutex& mainThreadMutex() | 4779 static Mutex& mainThreadMutex() |
4780 { | 4780 { |
4781 AtomicallyInitializedStatic(Mutex&, mainMutex = *new Mutex); | 4781 AtomicallyInitializedStaticReference(Mutex, mainMutex, new Mutex); |
4782 return mainMutex; | 4782 return mainMutex; |
4783 } | 4783 } |
4784 | 4784 |
4785 static ThreadCondition& mainThreadCondition() | 4785 static ThreadCondition& mainThreadCondition() |
4786 { | 4786 { |
4787 AtomicallyInitializedStatic(ThreadCondition&, mainCondition = *new ThreadCon
dition); | 4787 AtomicallyInitializedStaticReference(ThreadCondition, mainCondition, new Thr
eadCondition); |
4788 return mainCondition; | 4788 return mainCondition; |
4789 } | 4789 } |
4790 | 4790 |
4791 static void parkMainThread() | 4791 static void parkMainThread() |
4792 { | 4792 { |
4793 mainThreadCondition().wait(mainThreadMutex()); | 4793 mainThreadCondition().wait(mainThreadMutex()); |
4794 } | 4794 } |
4795 | 4795 |
4796 static void wakeMainThread() | 4796 static void wakeMainThread() |
4797 { | 4797 { |
4798 MutexLocker locker(mainThreadMutex()); | 4798 MutexLocker locker(mainThreadMutex()); |
4799 mainThreadCondition().signal(); | 4799 mainThreadCondition().signal(); |
4800 } | 4800 } |
4801 | 4801 |
4802 static Mutex& workerThreadMutex() | 4802 static Mutex& workerThreadMutex() |
4803 { | 4803 { |
4804 AtomicallyInitializedStatic(Mutex&, workerMutex = *new Mutex); | 4804 AtomicallyInitializedStaticReference(Mutex, workerMutex, new Mutex); |
4805 return workerMutex; | 4805 return workerMutex; |
4806 } | 4806 } |
4807 | 4807 |
4808 static ThreadCondition& workerThreadCondition() | 4808 static ThreadCondition& workerThreadCondition() |
4809 { | 4809 { |
4810 AtomicallyInitializedStatic(ThreadCondition&, workerCondition = *new ThreadC
ondition); | 4810 AtomicallyInitializedStaticReference(ThreadCondition, workerCondition, new T
hreadCondition); |
4811 return workerCondition; | 4811 return workerCondition; |
4812 } | 4812 } |
4813 | 4813 |
4814 static void parkWorkerThread() | 4814 static void parkWorkerThread() |
4815 { | 4815 { |
4816 workerThreadCondition().wait(workerThreadMutex()); | 4816 workerThreadCondition().wait(workerThreadMutex()); |
4817 } | 4817 } |
4818 | 4818 |
4819 static void wakeWorkerThread() | 4819 static void wakeWorkerThread() |
4820 { | 4820 { |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5076 // Passes if it doesn't crash. | 5076 // Passes if it doesn't crash. |
5077 TEST(HeapTest, GarbageCollectionDuringMixinConstruction) | 5077 TEST(HeapTest, GarbageCollectionDuringMixinConstruction) |
5078 { | 5078 { |
5079 ClassWithGarbageCollectingMixinConstructor* a = | 5079 ClassWithGarbageCollectingMixinConstructor* a = |
5080 new ClassWithGarbageCollectingMixinConstructor(); | 5080 new ClassWithGarbageCollectingMixinConstructor(); |
5081 a->verify(); | 5081 a->verify(); |
5082 } | 5082 } |
5083 | 5083 |
5084 static RecursiveMutex& recursiveMutex() | 5084 static RecursiveMutex& recursiveMutex() |
5085 { | 5085 { |
5086 AtomicallyInitializedStatic(RecursiveMutex&, recursiveMutex = *new Recursive
Mutex); | 5086 AtomicallyInitializedStaticReference(RecursiveMutex, recursiveMutex, new Rec
ursiveMutex); |
5087 return recursiveMutex; | 5087 return recursiveMutex; |
5088 } | 5088 } |
5089 | 5089 |
5090 class DestructorLockingObject : public GarbageCollectedFinalized<DestructorLocki
ngObject> { | 5090 class DestructorLockingObject : public GarbageCollectedFinalized<DestructorLocki
ngObject> { |
5091 public: | 5091 public: |
5092 static DestructorLockingObject* create() | 5092 static DestructorLockingObject* create() |
5093 { | 5093 { |
5094 return new DestructorLockingObject(); | 5094 return new DestructorLockingObject(); |
5095 } | 5095 } |
5096 | 5096 |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5532 // re-adjusting both start&end indices in terms of that expanded buffer. | 5532 // re-adjusting both start&end indices in terms of that expanded buffer. |
5533 EXPECT_EQ(80u, deque->size()); | 5533 EXPECT_EQ(80u, deque->size()); |
5534 i = 0; | 5534 i = 0; |
5535 for (const auto& intWrapper : *deque) { | 5535 for (const auto& intWrapper : *deque) { |
5536 EXPECT_EQ(i + 50, intWrapper->value()); | 5536 EXPECT_EQ(i + 50, intWrapper->value()); |
5537 i++; | 5537 i++; |
5538 } | 5538 } |
5539 } | 5539 } |
5540 | 5540 |
5541 } // namespace blink | 5541 } // namespace blink |
OLD | NEW |