medfall

A super great game engine
Log | Files | Refs

cli.hpp (1207B)


      1 /*  Relacy Race Detector
      2  *  Copyright (c) 2008-2013, Dmitry S. Vyukov
      3  *  All rights reserved.
      4  *  This software is provided AS-IS with no warranty, either express or implied.
      5  *  This software is distributed under a license and may not be copied,
      6  *  modified or distributed except as expressly authorized under the
      7  *  terms of the license contained in the file LICENSE in this distribution.
      8  */
      9 
     10 #ifndef RL_CLI_HPP
     11 #define RL_CLI_HPP
     12 #ifdef _MSC_VER
     13 #   pragma once
     14 #endif
     15 
     16 #include "base.hpp"
     17 #include "context_base.hpp"
     18 #include "atomic_fence.hpp"
     19 
     20 
     21 namespace rl
     22 {
     23 
     24 
     25 struct Thread
     26 {
     27     static void MemoryBarrier(debug_info_param info)
     28     {
     29         atomic_thread_fence(mo_seq_cst, info);
     30     }
     31 
     32     template<typename T>
     33     static T VolatileRead(generic_atomic<T, true> const& v, debug_info_param info)
     34     {
     35         return v.load(mo_acquire, info);
     36     }
     37 
     38     template<typename T>
     39     static void VolatileWrite(generic_atomic<T, true>& v, T x, debug_info_param info)
     40     {
     41         v.store(x, mo_release, info);
     42     }
     43 
     44     static void SpinWait(int iterations, debug_info_param info)
     45     {
     46         ctx().yield(iterations, info);
     47     }
     48 };
     49 
     50 }
     51 
     52 #endif