ObjFW  Diff

Differences From Artifact [e9519677f8]:

To Artifact [0fa68d097c]:


13
14
15
16
17
18
19

20
21
22
23
24


25
26
27
28
29
30
31
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#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];
}








>





>
>







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
 * file.
 */

#include "config.h"

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

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

#import "macros.h"

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

58
59
60
61
62
63
64


















65
66
67
68
69
70
71
72


73
74
75
76

- (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







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>








>
>




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

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

- (void)setName: (OFString*)name_
{
	OF_SETTER(name, name_, YES, YES)
}

- (OFString*)name
{
	OF_GETTER(name, YES)
}

- (OFString*)description
{
	if (name == nil)
		return [super description];

	return [OFString stringWithFormat: @"<%@: %@>", [self className], name];
}

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

	[name release];

	[super dealloc];
}
@end