1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2011 New Dream Network
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #ifndef CEPH_SIMPLE_SPIN_H
16 #define CEPH_SIMPLE_SPIN_H
20 inline void simple_spin_lock(std::atomic_flag& lock)
22 while(lock.test_and_set(std::memory_order_acquire))
26 inline void simple_spin_unlock(std::atomic_flag& lock)
28 lock.clear(std::memory_order_release);
31 inline void simple_spin_lock(std::atomic_flag *lock)
33 simple_spin_lock(*lock);
36 inline void simple_spin_unlock(std::atomic_flag *lock)
38 simple_spin_unlock(*lock);