ObjFW  Check-in [7c33158c22]

Overview
Comment:Add OFLocking protocol.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 7c33158c22bac1a6f8917855013fb57669beaff6ebec10d61ed00cc4f94e324c
User & Date: js on 2012-10-26 11:23:49
Other Links: manifest | tags
Context
2012-10-27
15:52
PLATFORMS.md: Add Mac OS X 10.8. check-in: 840ef61f18 user: js tags: trunk
2012-10-26
11:23
Add OFLocking protocol. check-in: 7c33158c22 user: js tags: trunk
11:04
Split OFThread.m into multiple files. check-in: 0a55edad35 user: js tags: trunk
Changes

Modified src/Makefile from [7a8233cdb8] to [e4b9bf7918].

68
69
70
71
72
73
74

75
76
77
78
79
80
81
       of_asprintf.m			\
       of_strptime.m			\
       unicode.m

INCLUDES := ${SRCS:.m=.h}		\
	    OFCollection.h		\
	    OFJSONRepresentation.h	\

	    OFSerialization.h		\
	    OFTLSSocket.h		\
	    ObjFW.h			\
	    asprintf.h			\
	    autorelease.h		\
	    ${ATOMIC_H}			\
	    instance.h			\







>







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
       of_asprintf.m			\
       of_strptime.m			\
       unicode.m

INCLUDES := ${SRCS:.m=.h}		\
	    OFCollection.h		\
	    OFJSONRepresentation.h	\
	    OFLocking.h			\
	    OFSerialization.h		\
	    OFTLSSocket.h		\
	    ObjFW.h			\
	    asprintf.h			\
	    autorelease.h		\
	    ${ATOMIC_H}			\
	    instance.h			\

Modified src/OFFile.m from [f6bb1bb8aa] to [ffd2b8da5e].

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

70
71
72
73
74
75
76
#import "OFChangeFileOwnerFailedException.h"
#import "OFCreateDirectoryFailedException.h"
#import "OFDeleteDirectoryFailedException.h"
#import "OFDeleteFileFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFLinkFailedException.h"
#import "OFMutexLockFailedException.h"
#import "OFMutexUnlockFailedException.h"
#import "OFNotImplementedException.h"
#import "OFOpenFileFailedException.h"
#import "OFOutOfMemoryException.h"
#import "OFReadFailedException.h"
#import "OFRenameFileFailedException.h"
#import "OFSeekFailedException.h"
#import "OFSymlinkFailedException.h"

#import "OFWriteFailedException.h"

#import "autorelease.h"
#import "macros.h"

#ifdef _WIN32
# import <windows.h>







|
<







>







54
55
56
57
58
59
60
61

62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#import "OFChangeFileOwnerFailedException.h"
#import "OFCreateDirectoryFailedException.h"
#import "OFDeleteDirectoryFailedException.h"
#import "OFDeleteFileFailedException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFLinkFailedException.h"
#import "OFLockFailedException.h"

#import "OFNotImplementedException.h"
#import "OFOpenFileFailedException.h"
#import "OFOutOfMemoryException.h"
#import "OFReadFailedException.h"
#import "OFRenameFileFailedException.h"
#import "OFSeekFailedException.h"
#import "OFSymlinkFailedException.h"
#import "OFUnlockFailedException.h"
#import "OFWriteFailedException.h"

#import "autorelease.h"
#import "macros.h"

#ifdef _WIN32
# import <windows.h>
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453

	if (owner == nil && group == nil)
		@throw [OFInvalidArgumentException exceptionWithClass: self
							     selector: _cmd];

# ifdef OF_THREADS
	if (!of_mutex_lock(&mutex))
		@throw [OFMutexLockFailedException exceptionWithClass: self
								mutex: nil];

	@try {
# endif
		if (owner != nil) {
			struct passwd *passwd;

			if ((passwd = getpwnam([owner cStringWithEncoding:







|
<







438
439
440
441
442
443
444
445

446
447
448
449
450
451
452

	if (owner == nil && group == nil)
		@throw [OFInvalidArgumentException exceptionWithClass: self
							     selector: _cmd];

# ifdef OF_THREADS
	if (!of_mutex_lock(&mutex))
		@throw [OFLockFailedException exceptionWithClass: self];


	@try {
# endif
		if (owner != nil) {
			struct passwd *passwd;

			if ((passwd = getpwnam([owner cStringWithEncoding:
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
						 group: group];

			gid = group_->gr_gid;
		}
# ifdef OF_THREADS
	} @finally {
		if (!of_mutex_unlock(&mutex))
			@throw [OFMutexUnlockFailedException
			    exceptionWithClass: self
					 mutex: nil];
	}
# endif

	if (chown([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    uid, gid))
		@throw [OFChangeFileOwnerFailedException
		    exceptionWithClass: self







|
|
<







472
473
474
475
476
477
478
479
480

481
482
483
484
485
486
487
						 group: group];

			gid = group_->gr_gid;
		}
# ifdef OF_THREADS
	} @finally {
		if (!of_mutex_unlock(&mutex))
			@throw [OFUnlockFailedException
			    exceptionWithClass: self];

	}
# endif

	if (chown([path cStringWithEncoding: OF_STRING_ENCODING_NATIVE],
	    uid, gid))
		@throw [OFChangeFileOwnerFailedException
		    exceptionWithClass: self

Added src/OFLocking.h version [0ad6f630ce].















































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"

/**
 * \brief A protocol for locks.
 */
@protocol OFLocking <OFObject>
/**
 * \brief Locks the lock.
 */
- (void)lock;

/**
 * \brief Tries to lock the lock.
 *
 * \return A boolean whether the lock could be locked
 */
- (BOOL)tryLock;

/**
 * \brief Unlocks the lock.
 */
- (void)unlock;
@end

Modified src/OFMutex.h from [a9c6524320] to [2f19637b86].

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
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"


#import "threading.h"

/**
 * \brief A class for creating mutual exclusions.
 */
@interface OFMutex: OFObject
{
	of_mutex_t mutex;
	BOOL initialized;
}

/**
 * \brief Creates a new mutex.
 *
 * \return A new autoreleased mutex.
 */
+ (instancetype)mutex;

- OF_initWithoutCreatingMutex;

/**
 * \brief Locks the mutex.
 */
- (void)lock;

/**
 * \brief Tries to lock the mutex.
 *
 * \return A boolean whether the mutex could be acquired
 */
- (BOOL)tryLock;

/**
 * \brief Unlocks the mutex.
 */
- (void)unlock;
@end







>






|











<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<

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
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"
#import "OFLocking.h"

#import "threading.h"

/**
 * \brief A class for creating mutual exclusions.
 */
@interface OFMutex: OFObject <OFLocking>
{
	of_mutex_t mutex;
	BOOL initialized;
}

/**
 * \brief Creates a new mutex.
 *
 * \return A new autoreleased mutex.
 */
+ (instancetype)mutex;



















@end

Modified src/OFMutex.m from [3c3018edf4] to [e9519677f8].

15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 */

#include "config.h"

#import "OFMutex.h"

#import "OFInitializationFailedException.h"
#import "OFMutexLockFailedException.h"
#import "OFMutexStillLockedException.h"
#import "OFMutexUnlockFailedException.h"

@implementation OFMutex
+ (instancetype)mutex
{
	return [[[self alloc] init] autorelease];
}








|
|
|







15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 */

#include "config.h"

#import "OFMutex.h"

#import "OFInitializationFailedException.h"
#import "OFLockFailedException.h"
#import "OFStillLockedException.h"
#import "OFUnlockFailedException.h"

@implementation OFMutex
+ (instancetype)mutex
{
	return [[[self alloc] init] autorelease];
}

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
	}

	initialized = YES;

	return self;
}

- OF_initWithoutCreatingMutex
{
	return [super init];
}

- (void)lock
{
	if (!of_mutex_lock(&mutex))
		@throw [OFMutexLockFailedException
		    exceptionWithClass: [self class]
				 mutex: self];
}

- (BOOL)tryLock
{
	return of_mutex_trylock(&mutex);
}

- (void)unlock
{
	if (!of_mutex_unlock(&mutex))
		@throw [OFMutexUnlockFailedException
		    exceptionWithClass: [self class]
				 mutex: self];
}

- (void)dealloc
{
	if (initialized)
		if (!of_mutex_free(&mutex))
			@throw [OFMutexStillLockedException
			    exceptionWithClass: [self class]
					 mutex: self];

	[super dealloc];
}
@end








<
<
<
<
<



<
|
|










<
|
|






|

|




<
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

	}

	initialized = YES;

	return self;
}






- (void)lock
{
	if (!of_mutex_lock(&mutex))

		@throw [OFLockFailedException exceptionWithClass: [self class]
							    lock: self];
}

- (BOOL)tryLock
{
	return of_mutex_trylock(&mutex);
}

- (void)unlock
{
	if (!of_mutex_unlock(&mutex))

		@throw [OFUnlockFailedException exceptionWithClass: [self class]
							      lock: self];
}

- (void)dealloc
{
	if (initialized)
		if (!of_mutex_free(&mutex))
			@throw [OFStillLockedException
			    exceptionWithClass: [self class]
					  lock: self];

	[super dealloc];
}
@end

Modified src/OFRecursiveMutex.h from [dd0c304280] to [6e1334c23c].

10
11
12
13
14
15
16
17



18
19
20
21
22
23
24
25

26







27
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFMutex.h"




/**
 * \brief A class for creating mutual exclusions which can be entered
 *	  recursively.
 */
@interface OFRecursiveMutex: OFMutex
{
	of_rmutex_t rmutex;

}







@end







|
>
>
>





|


>

>
>
>
>
>
>
>

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
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFObject.h"
#import "OFLocking.h"

#import "threading.h"

/**
 * \brief A class for creating mutual exclusions which can be entered
 *	  recursively.
 */
@interface OFRecursiveMutex: OFObject <OFLocking>
{
	of_rmutex_t rmutex;
	BOOL initialized;
}

/**
 * \brief Creates a new recursive mutex.
 *
 * \return A new autoreleased recursive mutex.
 */
+ (instancetype)mutex;
@end

Modified src/OFRecursiveMutex.m from [ef20679bce] to [2706783ddc].

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
 */

#include "config.h"

#import "OFRecursiveMutex.h"

#import "OFInitializationFailedException.h"
#import "OFMutexLockFailedException.h"
#import "OFMutexStillLockedException.h"
#import "OFMutexUnlockFailedException.h"

@implementation OFRecursiveMutex





- init
{
	self = [super OF_initWithoutCreatingMutex];

	if (!of_rmutex_new(&rmutex)) {
		Class c = [self class];
		[self release];
		@throw [OFInitializationFailedException exceptionWithClass: c];
	}

	initialized = YES;

	return self;
}

- (void)lock
{
	if (!of_rmutex_lock(&rmutex))
		@throw [OFMutexLockFailedException
		    exceptionWithClass: [self class]
				 mutex: self];
}

- (BOOL)tryLock
{
	return of_rmutex_trylock(&rmutex);
}

- (void)unlock
{
	if (!of_rmutex_unlock(&rmutex))
		@throw [OFMutexUnlockFailedException
		    exceptionWithClass: [self class]
				 mutex: self];
}

- (void)dealloc
{
	if (initialized)
		if (!of_rmutex_free(&rmutex))
			@throw [OFMutexStillLockedException
			    exceptionWithClass: [self class]
					 mutex: self];

	[super dealloc];
}
@end







|
|
|


>
>
>
>
>


|















<
|
|










<
|
|






|

|




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
 */

#include "config.h"

#import "OFRecursiveMutex.h"

#import "OFInitializationFailedException.h"
#import "OFLockFailedException.h"
#import "OFStillLockedException.h"
#import "OFUnlockFailedException.h"

@implementation OFRecursiveMutex
+ (instancetype)mutex
{
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

	if (!of_rmutex_new(&rmutex)) {
		Class c = [self class];
		[self release];
		@throw [OFInitializationFailedException exceptionWithClass: c];
	}

	initialized = YES;

	return self;
}

- (void)lock
{
	if (!of_rmutex_lock(&rmutex))

		@throw [OFLockFailedException exceptionWithClass: [self class]
							    lock: self];
}

- (BOOL)tryLock
{
	return of_rmutex_trylock(&rmutex);
}

- (void)unlock
{
	if (!of_rmutex_unlock(&rmutex))

		@throw [OFUnlockFailedException exceptionWithClass: [self class]
							      lock: self];
}

- (void)dealloc
{
	if (initialized)
		if (!of_rmutex_free(&rmutex))
			@throw [OFStillLockedException
			    exceptionWithClass: [self class]
					  lock: self];

	[super dealloc];
}
@end

Modified src/ObjFW.h from [2df4cec6a1] to [0cadaadec7].

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
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFInvalidJSONException.h"
#import "OFInvalidServerReplyException.h"
#import "OFLinkFailedException.h"
#import "OFListenFailedException.h"

#import "OFMalformedXMLException.h"
#import "OFMemoryNotPartOfObjectException.h"
#ifdef OF_THREADS
# import "OFMutexLockFailedException.h"
# import "OFMutexStillLockedException.h"
# import "OFMutexUnlockFailedException.h"
#endif
#import "OFNotConnectedException.h"
#import "OFNotImplementedException.h"
#import "OFOpenFileFailedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFReadOrWriteFailedException.h"
#import "OFRenameFileFailedException.h"
#import "OFSeekFailedException.h"
#import "OFSetOptionFailedException.h"

#import "OFSymlinkFailedException.h"
#ifdef OF_THREADS
# import "OFThreadJoinFailedException.h"
# import "OFThreadStartFailedException.h"
# import "OFThreadStillRunningException.h"
#endif
#import "OFTruncatedDataException.h"
#import "OFUnboundNamespaceException.h"

#import "OFUnsupportedProtocolException.h"
#import "OFWriteFailedException.h"

#import "macros.h"

#ifdef OF_PLUGINS
# import "OFPlugin.h"
#endif

#ifdef OF_ATOMIC_OPS
# import "atomic.h"
#endif


#ifdef OF_THREADS
# import "threading.h"
# import "OFThread.h"
# import "OFThreadPool.h"
# import "OFTLSKey.h"
# import "OFMutex.h"
# import "OFRecursiveMutex.h"







>


<
<
<
<
<










>








>













>







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
#import "OFInvalidArgumentException.h"
#import "OFInvalidEncodingException.h"
#import "OFInvalidFormatException.h"
#import "OFInvalidJSONException.h"
#import "OFInvalidServerReplyException.h"
#import "OFLinkFailedException.h"
#import "OFListenFailedException.h"
#import "OFLockFailedException.h"
#import "OFMalformedXMLException.h"
#import "OFMemoryNotPartOfObjectException.h"





#import "OFNotConnectedException.h"
#import "OFNotImplementedException.h"
#import "OFOpenFileFailedException.h"
#import "OFOutOfMemoryException.h"
#import "OFOutOfRangeException.h"
#import "OFReadFailedException.h"
#import "OFReadOrWriteFailedException.h"
#import "OFRenameFileFailedException.h"
#import "OFSeekFailedException.h"
#import "OFSetOptionFailedException.h"
#import "OFStillLockedException.h"
#import "OFSymlinkFailedException.h"
#ifdef OF_THREADS
# import "OFThreadJoinFailedException.h"
# import "OFThreadStartFailedException.h"
# import "OFThreadStillRunningException.h"
#endif
#import "OFTruncatedDataException.h"
#import "OFUnboundNamespaceException.h"
#import "OFUnlockFailedException.h"
#import "OFUnsupportedProtocolException.h"
#import "OFWriteFailedException.h"

#import "macros.h"

#ifdef OF_PLUGINS
# import "OFPlugin.h"
#endif

#ifdef OF_ATOMIC_OPS
# import "atomic.h"
#endif

#import "OFLocking.h"
#ifdef OF_THREADS
# import "threading.h"
# import "OFThread.h"
# import "OFThreadPool.h"
# import "OFTLSKey.h"
# import "OFMutex.h"
# import "OFRecursiveMutex.h"

Modified src/exceptions/Makefile from [c7632543f8] to [de8d20daa5].

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
       OFInvalidArgumentException.m		\
       OFInvalidEncodingException.m		\
       OFInvalidFormatException.m		\
       OFInvalidJSONException.m			\
       OFInvalidServerReplyException.m		\
       OFLinkFailedException.m			\
       OFListenFailedException.m		\

       OFMalformedXMLException.m		\
       OFMemoryNotPartOfObjectException.m	\
       OFMutexLockFailedException.m		\
       OFMutexStillLockedException.m		\
       OFMutexUnlockFailedException.m		\
       OFNotConnectedException.m		\
       OFNotImplementedException.m		\
       OFOpenFileFailedException.m		\
       OFOutOfMemoryException.m			\
       OFOutOfRangeException.m			\
       OFReadFailedException.m			\
       OFReadOrWriteFailedException.m		\
       OFRenameFileFailedException.m		\
       OFSeekFailedException.m			\
       OFSetOptionFailedException.m		\

       OFSymlinkFailedException.m		\
       OFThreadJoinFailedException.m		\
       OFThreadStartFailedException.m		\
       OFThreadStillRunningException.m		\
       OFTruncatedDataException.m		\
       OFUnboundNamespaceException.m		\

       OFUnsupportedProtocolException.m		\
       OFUnsupportedVersionException.m		\
       OFWriteFailedException.m

INCLUDES = ${SRCS:.m=.h}

include ../../buildsys.mk

CPPFLAGS += -I. -I.. -I../.. -I../runtime
LD = ${OBJC}







>


<
<
<










>






>










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
       OFInvalidArgumentException.m		\
       OFInvalidEncodingException.m		\
       OFInvalidFormatException.m		\
       OFInvalidJSONException.m			\
       OFInvalidServerReplyException.m		\
       OFLinkFailedException.m			\
       OFListenFailedException.m		\
       OFLockFailedException.m			\
       OFMalformedXMLException.m		\
       OFMemoryNotPartOfObjectException.m	\



       OFNotConnectedException.m		\
       OFNotImplementedException.m		\
       OFOpenFileFailedException.m		\
       OFOutOfMemoryException.m			\
       OFOutOfRangeException.m			\
       OFReadFailedException.m			\
       OFReadOrWriteFailedException.m		\
       OFRenameFileFailedException.m		\
       OFSeekFailedException.m			\
       OFSetOptionFailedException.m		\
       OFStillLockedException.m			\
       OFSymlinkFailedException.m		\
       OFThreadJoinFailedException.m		\
       OFThreadStartFailedException.m		\
       OFThreadStillRunningException.m		\
       OFTruncatedDataException.m		\
       OFUnboundNamespaceException.m		\
       OFUnlockFailedException.m		\
       OFUnsupportedProtocolException.m		\
       OFUnsupportedVersionException.m		\
       OFWriteFailedException.m

INCLUDES = ${SRCS:.m=.h}

include ../../buildsys.mk

CPPFLAGS += -I. -I.. -I../.. -I../runtime
LD = ${OBJC}

Added src/exceptions/OFLockFailedException.h version [34551c1887].













































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"
#import "OFLocking.h"

/**
 * \brief An exception indicating that locking a lock failed.
 */
@interface OFLockFailedException: OFException
{
	id <OFLocking> lock;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) id <OFLocking> lock;
#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param lock The lock which could not be locked
 * \return A new lock failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      lock: (id <OFLocking>)lock;

/**
 * Initializes an already allocated lock failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param lock The lock which could not be locked
 * \return An initialized lock failed exception
 */
- initWithClass: (Class)class_
	   lock: (id <OFLocking>)lock;

/**
 * \param The lock which could not be locked
 */
- (id <OFLocking>)lock;
@end

Added src/exceptions/OFLockFailedException.m version [573e15c5b2].







































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFLockFailedException.h"
#import "OFString.h"

#import "OFNotImplementedException.h"

#import "macros.h"

@implementation OFLockFailedException
+ (instancetype)exceptionWithClass: (Class)class_
			      lock: (id <OFLocking>)lock
{
	return [[[self alloc] initWithClass: class_
				       lock: lock] autorelease];
}

- initWithClass: (Class)class_
	   lock: (id <OFLocking>)lock_
{
	self = [super initWithClass: class_];

	lock = [lock_ retain];

	return self;
}

- (void)dealloc
{
	[lock release];

	[super dealloc];
}

- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"A lock of type %@ could not be locked in class %@!",
	    [(id)lock className], inClass];

	return description;
}

- (id <OFLocking>)lock
{
	OF_GETTER(lock, NO)
}
@end

Deleted src/exceptions/OFMutexLockFailedException.h version [2b5e9d9241].

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
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

@class OFMutex;

/**
 * \brief An exception indicating that locking a mutex failed.
 */
@interface OFMutexLockFailedException: OFException
{
	OFMutex *mutex;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFMutex *mutex;
#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param mutex The mutex which is could not be locked
 * \return A new mutex lock failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			     mutex: (OFMutex*)mutex;

/**
 * Initializes an already allocated mutex lock failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param mutex The mutex which is could not be locked
 * \return An initialized mutex lock failed exception
 */
- initWithClass: (Class)class_
	  mutex: (OFMutex*)mutex;

/**
 * \param The mutex which is could not be locked
 */
- (OFMutex*)mutex;
@end
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































Deleted src/exceptions/OFMutexLockFailedException.m version [f08d944c22].

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
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFMutexLockFailedException.h"
#import "OFString.h"
#import "OFMutex.h"

#import "OFNotImplementedException.h"

@implementation OFMutexLockFailedException
+ (instancetype)exceptionWithClass: (Class)class_
			     mutex: (OFMutex*)mutex
{
	return [[[self alloc] initWithClass: class_
				      mutex: mutex] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = [self class];
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	  mutex: (OFMutex*)mutex_
{
	self = [super initWithClass: class_];

	mutex = [mutex_ retain];

	return self;
}

- (void)dealloc
{
	[mutex release];

	[super dealloc];
}

- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"A mutex of class %@ could not be locked!", inClass];

	return description;
}

- (OFMutex*)mutex
{
	OF_GETTER(mutex, NO)
}
@end
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































Deleted src/exceptions/OFMutexStillLockedException.h version [ae45a21493].

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
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

@class OFMutex;

/**
 * \brief An exception indicating that a mutex is still locked.
 */
@interface OFMutexStillLockedException: OFException
{
	OFMutex *mutex;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFMutex *mutex;
#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param mutex The mutex which is still locked
 * \return A new mutex still locked exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			     mutex: (OFMutex*)mutex;

/**
 * Initializes an already allocated mutex still locked exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param mutex The mutex which is still locked
 * \return An initialized mutex still locked exception
 */
- initWithClass: (Class)class_
	  mutex: (OFMutex*)mutex;

/**
 * \return The mutex which is still locked
 */
- (OFMutex*)mutex;
@end
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































Deleted src/exceptions/OFMutexStillLockedException.m version [b67597220c].

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
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFMutexStillLockedException.h"
#import "OFString.h"
#import "OFMutex.h"

#import "OFNotImplementedException.h"

@implementation OFMutexStillLockedException
+ (instancetype)exceptionWithClass: (Class)class_
			     mutex: (OFMutex*)mutex
{
	return [[[self alloc] initWithClass: class_
				      mutex: mutex] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = [self class];
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	  mutex: (OFMutex*)mutex_
{
	self = [super initWithClass: class_];

	mutex = [mutex_ retain];

	return self;
}

- (void)dealloc
{
	[mutex release];

	[super dealloc];
}

- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Deallocation of a mutex of type %@ was tried, even though it "
	    @"was still locked!", inClass];

	return description;
}

- (OFMutex*)mutex
{
	OF_GETTER(mutex, NO)
}
@end
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<




















































































































































Deleted src/exceptions/OFMutexUnlockFailedException.h version [e315fb187a].

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
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"

@class OFMutex;

/**
 * \brief An exception indicating that unlocking a mutex failed.
 */
@interface OFMutexUnlockFailedException: OFException
{
	OFMutex *mutex;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) OFMutex *mutex;
#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param mutex The mutex which could not be unlocked
 * \return A new mutex unlock failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			     mutex: (OFMutex*)mutex;

/**
 * Initializes an already allocated mutex unlock failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param mutex The mutex which could not be unlocked
 * \return An initialized mutex unlock failed exception
 */
- initWithClass: (Class)class_
	  mutex: (OFMutex*)mutex;

/**
 * \return The mutex which could not be unlocked
 */
- (OFMutex*)mutex;
@end
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














































































































Deleted src/exceptions/OFMutexUnlockFailedException.m version [b30cc8b0ab].

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
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFMutexUnlockFailedException.h"
#import "OFString.h"
#import "OFMutex.h"

#import "OFNotImplementedException.h"

@implementation OFMutexUnlockFailedException
+ (instancetype)exceptionWithClass: (Class)class_
			     mutex: (OFMutex*)mutex
{
	return [[[self alloc] initWithClass: class_
				      mutex: mutex] autorelease];
}

- initWithClass: (Class)class_
{
	Class c = [self class];
	[self release];
	@throw [OFNotImplementedException exceptionWithClass: c
						    selector: _cmd];
}

- initWithClass: (Class)class_
	  mutex: (OFMutex*)mutex_
{
	self = [super initWithClass: class_];

	mutex = [mutex_ retain];

	return self;
}

- (void)dealloc
{
	[mutex release];

	[super dealloc];
}

- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"A mutex of class %@ could not be unlocked!", inClass];

	return description;
}

- (OFMutex*)mutex
{
	OF_GETTER(mutex, NO)
}
@end
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<


















































































































































Added src/exceptions/OFStillLockedException.h version [da3d6698c1].













































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"
#import "OFLocking.h"

/**
 * \brief An exception indicating that a lock is still locked.
 */
@interface OFStillLockedException: OFException
{
	id <OFLocking> lock;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) id <OFLocking> lock;
#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param lock The lock which is still locked
 * \return A new still locked exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      lock: (id <OFLocking>)lock;

/**
 * Initializes an already allocated still locked exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param lock The lock which is still locked
 * \return An initialized still locked exception
 */
- initWithClass: (Class)class_
	   lock: (id <OFLocking>)lock;

/**
 * \return The lock which is still locked
 */
- (id <OFLocking>)lock;
@end

Added src/exceptions/OFStillLockedException.m version [89bf01b698].







































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFStillLockedException.h"
#import "OFString.h"

#import "OFNotImplementedException.h"

#import "macros.h"

@implementation OFStillLockedException
+ (instancetype)exceptionWithClass: (Class)class_
			      lock: (id <OFLocking>)lock
{
	return [[[self alloc] initWithClass: class_
				       lock: lock] autorelease];
}

- initWithClass: (Class)class_
	   lock: (id <OFLocking>)lock_
{
	self = [super initWithClass: class_];

	lock = [lock_ retain];

	return self;
}

- (void)dealloc
{
	[lock release];

	[super dealloc];
}

- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"Deallocation of a lock of type %@ was tried in class %@, even "
	    @"though it was still locked!", [(id)lock className], inClass];

	return description;
}

- (id <OFLocking>)lock
{
	OF_GETTER(lock, NO)
}
@end

Added src/exceptions/OFUnlockFailedException.h version [7d2a66af7c].













































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#import "OFException.h"
#import "OFLocking.h"

/**
 * \brief An exception indicating that unlocking a lock failed.
 */
@interface OFUnlockFailedException: OFException
{
	id <OFLocking> lock;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, retain, nonatomic) id <OFLocking> lock;
#endif

/**
 * \param class_ The class of the object which caused the exception
 * \param lock The lock which could not be unlocked
 * \return A new unlock failed exception
 */
+ (instancetype)exceptionWithClass: (Class)class_
			      lock: (id <OFLocking>)lock;

/**
 * Initializes an already allocated unlock failed exception.
 *
 * \param class_ The class of the object which caused the exception
 * \param lock The lock which could not be unlocked
 * \return An initialized unlock failed exception
 */
- initWithClass: (Class)class_
	   lock: (id <OFLocking>)lock;

/**
 * \return The lock which could not be unlocked
 */
- (id <OFLocking>)lock;
@end

Added src/exceptions/OFUnlockFailedException.m version [ef011d99a3].







































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
/*
 * Copyright (c) 2008, 2009, 2010, 2011, 2012
 *   Jonathan Schleifer <js@webkeks.org>
 *
 * All rights reserved.
 *
 * This file is part of ObjFW. It may be distributed under the terms of the
 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
 * the packaging of this file.
 *
 * Alternatively, it may be distributed under the terms of the GNU General
 * Public License, either version 2 or 3, which can be found in the file
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

#import "OFUnlockFailedException.h"
#import "OFString.h"

#import "OFNotImplementedException.h"

#import "macros.h"

@implementation OFUnlockFailedException
+ (instancetype)exceptionWithClass: (Class)class_
			      lock: (id <OFLocking>)lock
{
	return [[[self alloc] initWithClass: class_
				       lock: lock] autorelease];
}

- initWithClass: (Class)class_
	   lock: (id <OFLocking>)lock_
{
	self = [super initWithClass: class_];

	lock = [lock_ retain];

	return self;
}

- (void)dealloc
{
	[lock release];

	[super dealloc];
}

- (OFString*)description
{
	if (description != nil)
		return description;

	description = [[OFString alloc] initWithFormat:
	    @"A lock of class %@ could not be unlocked in class %@!",
	    [(id)lock className], inClass];

	return description;
}

- (id <OFLocking>)lock
{
	OF_GETTER(lock, NO)
}
@end