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 // UNSUPPORTED: libcpp-has-no-threads
     11 
     12 // <mutex>
     13 
     14 // template <class Mutex> class unique_lock;
     15 
     16 // void swap(unique_lock& u);
     17 
     18 #include <mutex>
     19 #include <cassert>
     20 
     21 struct mutex
     22 {
     23     void lock() {}
     24     void unlock() {}
     25 };
     26 
     27 mutex m;
     28 
     29 int main()
     30 {
     31     std::unique_lock<mutex> lk1(m);
     32     std::unique_lock<mutex> lk2;
     33     lk1.swap(lk2);
     34     assert(lk1.mutex() == nullptr);
     35     assert(lk1.owns_lock() == false);
     36     assert(lk2.mutex() == &m);
     37     assert(lk2.owns_lock() == true);
     38 }
     39