Ejemplo n.º 1
0
static void bounce_weak_weak_ref(void* data) {
    SkWeakRefCnt* ref = static_cast<SkWeakRefCnt*>(data);
    for (int i = 0; i < 100000; ++i) {
        ref->weak_ref();
        ref->weak_unref();
    }
}
Ejemplo n.º 2
0
 virtual void onDraw(const int loops, SkCanvas*) {
     for (int i = 0; i < loops; ++i) {
         SkWeakRefCnt ref;
         for (int j = 0; j < M; ++j) {
             ref.ref();
             ref.unref();
         }
     }
 }
Ejemplo n.º 3
0
 void onDraw(const int loops, SkCanvas*) override {
     for (int i = 0; i < loops; ++i) {
         SkWeakRefCnt* ref = new SkWeakRefCnt();
         for (int j = 0; j < M; ++j) {
             ref->ref();
             ref->unref();
         }
         ref->unref();
     }
 }
Ejemplo n.º 4
0
static void test_weakRefCnt(skiatest::Reporter* reporter) {
    SkWeakRefCnt* ref = new SkWeakRefCnt();

    std::thread thing1(bounce_ref, ref);
    std::thread thing2(bounce_ref, ref);
    std::thread thing3(bounce_weak_ref, ref);
    std::thread thing4(bounce_weak_weak_ref, ref);

    thing1.join();
    thing2.join();
    thing3.join();
    thing4.join();

    REPORTER_ASSERT(reporter, ref->unique());
    SkDEBUGCODE(REPORTER_ASSERT(reporter, ref->getWeakCnt() == 1));
    ref->unref();
}