/usr/include/wombat/MRSWLock.h is in libmama-dev 2.2.2.1-11.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | /* $Id$
*
* OpenMAMA: The open middleware agnostic messaging API
* Copyright (C) 2011 NYSE Technologies, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef MRSWLOCK_H
#define MRSWLOCK_H
/* ********************************************************** */
/* Includes. */
/* ********************************************************** */
#include "wlock.h"
#include "wombat/wSemaphore.h"
/* ********************************************************** */
/* Type Defines. */
/* ********************************************************** */
/* Defines the return code used in this file. */
typedef int MRSW_RESULT;
#define MRSW_S_OK 0 /* Function succeeded. */
#define MRSW_E_INVALIDARG 1 /* Invalid arguments. */
#define MRSW_E_OUTOFMEMORY 2 /* No more memory. */
#define MRSW_E_SYSTEM 3 /* System error. */
/* ********************************************************** */
/* Structures. */
/* ********************************************************** */
/* This structure contains all the variables needed to implement the lock. */
typedef struct MRSWLock
{
/* The number of reader locks currently being held. */
long m_numberReaders;
/* The number of times the current thread has re-acquire the write lock. */
long m_numberWriters;
/* This event is signaled when there are no locks. Note that a semaphore
* with a count of 0 is used as we don't have a cross platform event.
*/
wsem_t m_noLocksEvent;
/* Mutex protects access to this structure. */
wLock m_mutex;
/* The Id of the thread that holds the write lock. */
long m_writeThreadId;
} MRSWLock, * PMRSWLock;
/* ********************************************************** */
/* Function Prototypes. */
/* ********************************************************** */
/**
* This function will acquire the lock. This function must be accompanied by a call to
* MRSWLock_release.
* @param lock (in) The lock created by a called to MRSWLock_create.
* @param read (in) Non-zero to acquire a read lock, 0 to acquire a write lock.
* @return one of the MRSW_RESULT codes.
*/
COMMONExpDLL
extern MRSW_RESULT
MRSWLock_acquire(
PMRSWLock lock,
int read);
/**
* This function will create a new multiple reader / single writer lock.
* @param lock (out) To return the lock object, free this by calling MRSW_release.
* @return one of the MRSW_RESULT codes.
*/
COMMONExpDLL
extern MRSW_RESULT
MRSWLock_create(
PMRSWLock *lock);
/**
* This function will downgrade a writer lock to a reader lock.
* @param lock (in) The lock created by a called to MRSWLock_create.
* @return one of the MRSW_RESULT codes.
*/
COMMONExpDLL
extern MRSW_RESULT
MRSWLock_downgrade(
PMRSWLock lock);
/**
* This function will free the lock object.
* @param lock (in) The lock created by a called to MRSWLock_create.
* @return one of the MRSW_RESULT codes.
*/
COMMONExpDLL
extern MRSW_RESULT
MRSWLock_free(
PMRSWLock lock);
/**
* This function will return the Id of the thread that currently holds the
* write lock.
* @param lock (in) The lock created by a called to MRSWLock_create.
* @return The write thread Id or 0 if no thread holds the write lock.
*/
COMMONExpDLL
extern long
MRSWLock_getWriteThreadId(
PMRSWLock lock);
/**
* This function will releae the lock.
* @param lock (in) The lock created by a called to MRSWLock_create.
* @param read (in) Non-zero to release a read lock, 0 to release a write lock.
* @return one of the MRSW_RESULT codes.
*/
COMMONExpDLL
extern MRSW_RESULT
MRSWLock_release(
PMRSWLock lock,
int read);
/**
* This function will upgrade a reader lock to a writer lock. Note that this function
* will only work if the current thread only holds 1 instance of the reader lock.
* @param lock (in) The lock created by a called to MRSWLock_create.
* @return one of the MRSW_RESULT codes.
*/
COMMONExpDLL
extern MRSW_RESULT
MRSWLock_upgrade(
PMRSWLock lock);
#endif
|