/usr/include/GNUstep/Foundation/NSLock.h is in libgnustep-base-dev 1.22.1-2ubuntu2.
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 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | /*
NSLock.h
Definitions for locking protocol and classes
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Scott Christley <scottc@net-community.com>
Date: 1996
This file is part of the GNUstep Objective-C Library.
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 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
Library General Public License for more details.
If you are interested in a warranty or support for this source code,
contact Scott Christley <scottc@net-community.com> for more information.
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 02111 USA.
*/
#ifndef __NSLock_h_GNUSTEP_BASE_INCLUDE
#define __NSLock_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#import <GNUstepBase/GSConfig.h>
#import <Foundation/NSObject.h>
#if defined(__cplusplus)
extern "C" {
#endif
/**
* Protocol defining lock and unlock operations.
*/
@protocol NSLocking
/**
* Block until acquiring lock.
*/
- (void) lock;
/**
* Relinquish lock.
*/
- (void) unlock;
@end
/**
* <p>Simplest lock for protecting critical sections of code.
* </p>
* <p>An <code>NSLock</code> is used in multi-threaded applications to protect
* critical pieces of code. While one thread holds a lock within a piece of
* code, another thread cannot execute that code until the first thread has
* given up its hold on the lock. The limitation of <code>NSLock</code> is
* that you can only lock an <code>NSLock</code> once and it must be unlocked
* before it can be acquired again.<br /> Other lock classes, notably
* [NSRecursiveLock], have different restrictions.
* </p>
*/
@interface NSLock : NSObject <NSLocking>
{
#if GS_EXPOSE(NSLock)
@private
gs_mutex_t _mutex;
NSString *_name;
#endif
}
/**
* Try to acquire lock and return immediately, YES if succeeded, NO if not.
*/
- (BOOL) tryLock;
/**
* Try to acquire lock and return before limit, YES if succeeded, NO if not.
*/
- (BOOL) lockBeforeDate: (NSDate*)limit;
/**
* Block until acquiring lock.
*/
- (void) lock;
/**
* Relinquish lock.
*/
- (void) unlock;
#if OS_API_VERSION(100500,GS_API_LATEST)
/** Return the name of the receiver or nil of none has been set.
*/
- (NSString*) name;
/** Sets the name of the receiver (for use in debugging).
*/
- (void) setName: (NSString*)name;
#endif
@end
/**
* NSCondition provides an interface to POSIX condition variables.
*/
@interface NSCondition : NSObject <NSLocking>
{
#if GS_EXPOSE(NSCondition)
@private
gs_cond_t _condition;
gs_mutex_t _mutex;
NSString *_name;
#endif
}
/**
* Blocks and atomically unlocks the receiver.
* This method should only be called when the receiver is locked.
* The caller will then block until the receiver is sent either a -signal
* or -broadcast message from another thread. At which
* point, the calling thread will reacquire the lock.
*/
- (void) wait;
/**
* Blocks the calling thread and acquires the lock, in the same way as -wait.
* Returns YES if the condition is signaled, or NO if the timeout is reached.
*/
- (BOOL) waitUntilDate: (NSDate*)limit;
/**
* Wakes wany one of the threads that are waiting on this condition.
*/
- (void) signal;
/**
* Wakes all threads that are waiting on this condition.
*/
- (void) broadcast;
/**
* Sets the name used for debugging messages.
*/
- (void) setName: (NSString*)newName;
/**
* Returns the name used for debugging messages.
*/
- (NSString*) name;
@end
/**
* Lock that allows user to request it only when an internal integer
* condition is equal to a particular value. The condition is set on
* initialization and whenever the lock is relinquished.
*/
@interface NSConditionLock : NSObject <NSLocking>
{
#if GS_EXPOSE(NSConditionLock)
@private
NSCondition *_condition;
int _condition_value;
NSString *_name;
#endif
}
/**
* Initialize lock with given condition.
*/
- (id) initWithCondition: (NSInteger)value;
/**
* Return the current condition of the lock.
*/
- (NSInteger) condition;
/*
* Acquiring and releasing the lock.
*/
/**
* Acquire lock when it is available and the internal condition is equal to
* value. Blocks until this occurs.
*/
- (void) lockWhenCondition: (NSInteger)value;
/**
* Relinquish the lock, setting internal condition to value.
*/
- (void) unlockWithCondition: (NSInteger)value;
/**
* Try to acquire lock regardless of condition and return immediately, YES if
* succeeded, NO if not.
*/
- (BOOL) tryLock;
/**
* Try to acquire lock if condition is equal to value and return immediately
* in any case, YES if succeeded, NO if not.
*/
- (BOOL) tryLockWhenCondition: (NSInteger)value;
/*
* Acquiring the lock with a date condition.
*/
/**
* Try to acquire lock and return before limit, YES if succeeded, NO if not.
*/
- (BOOL) lockBeforeDate: (NSDate*)limit;
/**
* Try to acquire lock, when internal condition is equal to condition_to_meet,
* and return before limit, YES if succeeded, NO if not.
*/
- (BOOL) lockWhenCondition: (NSInteger)condition_to_meet
beforeDate: (NSDate*)limitDate;
/**
* Block until acquiring lock.
*/
- (void) lock;
/**
* Relinquish lock.
*/
- (void) unlock;
#if OS_API_VERSION(100500,GS_API_LATEST)
/** Return the name of the receiver or nil of none has been set.
*/
- (NSString*) name;
/** Sets the name of the receiver (for use in debugging).
*/
- (void) setName: (NSString*)name;
#endif
@end
/**
* Allows the lock to be recursively acquired by the same thread.
*
* If the same thread locks the mutex (n) times then that same
* thread must also unlock it (n) times before another thread
* can acquire the lock.
*/
@interface NSRecursiveLock : NSObject <NSLocking>
{
#if GS_EXPOSE(NSRecursiveLock)
@private
gs_mutex_t _mutex;
NSString *_name;
#endif
}
/**
* Try to acquire lock regardless of condition and return immediately, YES if
* succeeded, NO if not.
*/
- (BOOL) tryLock;
/**
* Try to acquire lock and return before limit, YES if succeeded, NO if not.
*/
- (BOOL) lockBeforeDate: (NSDate*)limit;
/**
* Block until acquiring lock.
*/
- (void) lock;
/**
* Relinquish lock.
*/
- (void) unlock;
#if OS_API_VERSION(100500,GS_API_LATEST)
/** Return the name of the receiver or nil of none has been set.
*/
- (NSString*) name;
/** Sets the name of the receiver (for use in debugging).
*/
- (void) setName: (NSString*)name;
#endif
@end
#if defined(__cplusplus)
}
#endif
#if !NO_GNUSTEP && !defined(GNUSTEP_BASE_INTERNAL)
#import <GNUstepBase/NSLock+GNUstepBase.h>
#endif
#endif /* __NSLock_h_GNUSTEP_BASE_INCLUDE */
|