Ignore:
Timestamp:
May 5, 2016, 1:06:20 PM (9 years ago)
Author:
Frederik Heber <heber@…>
Children:
c1e104
Parents:
039e15
git-author:
Frederik Heber <heber@…> (05/05/16 09:20:08)
git-committer:
Frederik Heber <heber@…> (05/05/16 13:06:20)
Message:

Singleton extended to also return AtomicInstance-wrapped instance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Patterns/unittests/SingletonUnitTest.cpp

    r039e15 rc6a59b  
    8181CONSTRUCT_SINGLETON(SingletonStub2);
    8282
    83 void SingletonTest::setUp(){}
     83void SingletonTest::setUp()
     84{
     85  ASSERT_DO(Assert::Throw);
     86}
     87
    8488void SingletonTest::tearDown(){}
    8589
     
    152156  // mechanism. Check with Valgrind to see if memory-leak occurs
    153157  std::cout << "Not purging Singleton!\n Check with Valgrind to see if automatic purgins is working!" << std::endl;
     158}
    154159
     160void SingletonTest::LockedTest(){
     161  const AtomicInstance<SingletonStub1> ptr_1_1(SingletonStub1::getLockedInstance());
     162  const SingletonStub1 &test_1 = *ptr_1_1;
     163
     164  // this deadlocks
     165//  AtomicInstance<SingletonStub1> ptr_1_2(SingletonStub1::getLockedInstance());
     166
     167  AtomicInstance<SingletonStub2> ptr_2_1(SingletonStub2::getLockedInstance());
     168  SingletonStub2 &test_2 = *ptr_2_1;
     169
     170  // this deadlocks
     171//  AtomicInstance<SingletonStub2> ptr_2_2(SingletonStub2::getLockedInstance());
    155172}
Note: See TracChangeset for help on using the changeset viewer.