sc_mutex.hh revision 13199
15314Sstever@gmail.com/* 25314Sstever@gmail.com * Copyright 2018 Google, Inc. 35314Sstever@gmail.com * 45314Sstever@gmail.com * Redistribution and use in source and binary forms, with or without 55314Sstever@gmail.com * modification, are permitted provided that the following conditions are 65314Sstever@gmail.com * met: redistributions of source code must retain the above copyright 75314Sstever@gmail.com * notice, this list of conditions and the following disclaimer; 85314Sstever@gmail.com * redistributions in binary form must reproduce the above copyright 95314Sstever@gmail.com * notice, this list of conditions and the following disclaimer in the 105314Sstever@gmail.com * documentation and/or other materials provided with the distribution; 115314Sstever@gmail.com * neither the name of the copyright holders nor the names of its 125314Sstever@gmail.com * contributors may be used to endorse or promote products derived from 135314Sstever@gmail.com * this software without specific prior written permission. 145314Sstever@gmail.com * 155314Sstever@gmail.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 165314Sstever@gmail.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 175314Sstever@gmail.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 185314Sstever@gmail.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 195314Sstever@gmail.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 205314Sstever@gmail.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 215314Sstever@gmail.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 225314Sstever@gmail.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 235314Sstever@gmail.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 245314Sstever@gmail.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 255314Sstever@gmail.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 265314Sstever@gmail.com * 275314Sstever@gmail.com * Authors: Gabe Black 285314Sstever@gmail.com */ 295314Sstever@gmail.com 305314Sstever@gmail.com#ifndef __SYSTEMC_EXT_CHANNEL_SC_MUTEX_HH__ 315314Sstever@gmail.com#define __SYSTEMC_EXT_CHANNEL_SC_MUTEX_HH__ 325314Sstever@gmail.com 335314Sstever@gmail.com#include "../core/sc_event.hh" 345314Sstever@gmail.com#include "../core/sc_object.hh" 355314Sstever@gmail.com#include "../core/sc_process_handle.hh" 365314Sstever@gmail.com#include "sc_mutex_if.hh" 375314Sstever@gmail.com 385314Sstever@gmail.comnamespace sc_core 395315Sstever@gmail.com{ 405315Sstever@gmail.com 415315Sstever@gmail.comclass sc_mutex : public sc_mutex_if, public sc_object 425315Sstever@gmail.com{ 435315Sstever@gmail.com public: 445314Sstever@gmail.com sc_mutex(); 455314Sstever@gmail.com explicit sc_mutex(const char *name); 465314Sstever@gmail.com 475314Sstever@gmail.com virtual int lock(); 485314Sstever@gmail.com virtual int trylock(); 495314Sstever@gmail.com virtual int unlock(); 505314Sstever@gmail.com 515314Sstever@gmail.com virtual const char *kind() const { return "sc_mutex"; } 525314Sstever@gmail.com 535314Sstever@gmail.com private: 545314Sstever@gmail.com // Disabled 555314Sstever@gmail.com sc_mutex(const sc_mutex &) : sc_interface(), sc_mutex_if(), sc_object() {} 56 sc_mutex &operator = (const sc_mutex &) { return *this; } 57 58 sc_process_handle holder; 59 sc_event unlockEvent; 60}; 61 62} // namespace sc_core 63 64#endif //__SYSTEMC_EXT_CHANNEL_SC_MUTEX_HH__ 65