All Downloads are FREE. Search and download functionalities are using the official Maven repository.

z3-z3-4.13.0.src.util.mutex.h Maven / Gradle / Ivy

The newest version!
/*++
Copyright (c) 2019 Microsoft Corporation

Module Name:

    mutex.h

Abstract:

    Auxiliary macros for mutual exclusion

--*/
#pragma once

#ifdef SINGLE_THREAD

template using atomic = T;

#define ATOMIC_EXCHANGE(ret, var, val) ret = var; var = val

struct mutex {
  void lock() {}
  void unlock() {}
};

struct lock_guard {
  lock_guard(mutex &) {}
};

#define DECLARE_MUTEX(name) mutex *name = nullptr
#define DECLARE_INIT_MUTEX(name) mutex *name = nullptr
#define ALLOC_MUTEX(name) (void)0
#define DEALLOC_MUTEX(name) (void)0

#else
#include 
#include 

template using atomic = std::atomic;
typedef std::mutex mutex;
typedef std::lock_guard lock_guard;

#define ATOMIC_EXCHANGE(ret, var, val) ret = var.exchange(val)
#define DECLARE_MUTEX(name) mutex *name = nullptr
#define DECLARE_INIT_MUTEX(name) mutex *name = new mutex
#define ALLOC_MUTEX(name) name = alloc(mutex)
#define DEALLOC_MUTEX(name) dealloc(name)

#endif




© 2015 - 2024 Weber Informatics LLC | Privacy Policy