Файли
rocm-systems/rocclr/runtime/thread/semaphore.hpp
T
foreman 90c15d9f06 P4 to Git Change 1082378 by lmoriche@lmoriche_opencl_dev on 2014/09/29 17:08:11
ECR #304775 - Replace amd::Atomic with std::atomic

	Pre-checkin: http://ocltc.amd.com:8111/viewModification.html?modId=40639&personal=true&buildTypeId=&tab=vcsModificationBuilds&show_all_builds=true

Affected files ...

... //depot/stg/opencl/drivers/opencl/runtime/os/os_posix.cpp#38 edit
... //depot/stg/opencl/drivers/opencl/runtime/os/os_win32.cpp#40 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.cpp#64 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/command.hpp#73 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.cpp#108 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.hpp#86 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/runtime.cpp#33 edit
... //depot/stg/opencl/drivers/opencl/runtime/thread/monitor.hpp#6 edit
... //depot/stg/opencl/drivers/opencl/runtime/thread/semaphore.cpp#6 edit
... //depot/stg/opencl/drivers/opencl/runtime/thread/semaphore.hpp#6 edit
... //depot/stg/opencl/drivers/opencl/runtime/utils/util.hpp#10 edit
2014-09-29 17:38:55 -04:00

66 рядки
1.1 KiB
C++

//
// Copyright (c) 2008,2010 Advanced Micro Devices, Inc. All rights reserved.
//
#ifndef SEMAPHORE_HPP_
#define SEMAPHORE_HPP_
#include "top.hpp"
#include "utils/util.hpp"
#include <atomic>
#if defined(__linux__)
# include <semaphore.h>
#endif /*linux*/
namespace amd {
/*! \addtogroup Threads
* @{
*
* \addtogroup Synchronization
* @{
*/
class Thread;
//! \brief Counting semaphore
class Semaphore : public HeapObject
{
private:
std::atomic_int state_; //!< This semaphore's value.
#ifdef _WIN32
void* handle_; //!< The semaphore object's handle.
char padding_[64-sizeof(void*)-sizeof(std::atomic_int)];
#else // !_WIN32
sem_t sem_; //!< The semaphore object's identifier.
char padding_[64-sizeof(sem_t)-sizeof(std::atomic_int)];
#endif /*!_WIN32*/
public:
Semaphore();
~Semaphore();
//! \brief Decrement this semaphore
void wait();
//! \brief Increment this semaphore
void post();
//! \brief Reset this semaphore.
void reset()
{
state_.store(0, std::memory_order_release);
}
};
/*! @}
* @}
*/
} // namespace amd
#endif /*SEMAPHORE_HPP_*/