Home | History | Annotate | Download | only in thread.lock.unique.mod
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <mutex>
     11 
     12 // template <class Mutex> class unique_lock;
     13 
     14 // void swap(unique_lock& u);
     15 
     16 #include <mutex>
     17 #include <cassert>
     18 
     19 struct mutex
     20 {
     21     void lock() {}
     22     void unlock() {}
     23 };
     24 
     25 mutex m;
     26 
     27 int main()
     28 {
     29     std::unique_lock<mutex> lk1(m);
     30     std::unique_lock<mutex> lk2;
     31     lk1.swap(lk2);
     32     assert(lk1.mutex() == nullptr);
     33     assert(lk1.owns_lock() == false);
     34     assert(lk2.mutex() == &m);
     35     assert(lk2.owns_lock() == true);
     36 }
     37