SpECTRE Documentation Coverage Report
Current view: top level - Parallel - NodeLock.hpp Hit Total Coverage
Commit: 9ddc33268b29014a4956c8f0c24ca90b397463e1 Lines: 1 16 6.2 %
Date: 2024-04-26 20:00:04
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include <charm++.h>
       7             : #include <memory>
       8             : 
       9             : #include "Parallel/Spinlock.hpp"
      10             : 
      11             : /// \cond
      12             : namespace PUP {
      13             : class er;
      14             : }  // namespace PUP
      15             : /// \endcond
      16             : 
      17             : namespace Parallel {
      18             : 
      19             : /*!
      20             :  * \ingroup ParallelGroup
      21             :  * \brief A typesafe wrapper for a lock for synchronization of shared resources
      22             :  * on a given node, with safe creation, destruction, and serialization.
      23             :  *
      24             :  * \note If a locked NodeLock is serialized, it is deserialized as unlocked.
      25             :  */
      26           1 : class NodeLock {
      27             :  public:
      28           0 :   NodeLock();
      29             : 
      30           0 :   explicit NodeLock(CkMigrateMessage* /*message*/);
      31             : 
      32           0 :   NodeLock(const NodeLock&) = delete;
      33           0 :   NodeLock& operator=(const NodeLock&) = delete;
      34           0 :   NodeLock(NodeLock&& moved_lock) noexcept;
      35           0 :   NodeLock& operator=(NodeLock&& moved_lock) noexcept;
      36           0 :   ~NodeLock();
      37             : 
      38           0 :   void lock();
      39             : 
      40           0 :   bool try_lock();
      41             : 
      42           0 :   void unlock();
      43             : 
      44           0 :   void destroy();
      45             : 
      46           0 :   bool is_destroyed() { return nullptr == lock_; }
      47             : 
      48             :   // NOLINTNEXTLINE(google-runtime-references)
      49           0 :   void pup(PUP::er& p);
      50             : 
      51             :  private:
      52           0 :   std::unique_ptr<Spinlock> lock_;
      53             : };
      54             : }  // namespace Parallel

Generated by: LCOV version 1.14