ObjFW  Diff

Differences From Artifact [03afd45a89]:

To Artifact [d5036265a2]:


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
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

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

	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)setName: (OFString*)name_
{
	OF_SETTER(name, name_, YES, 1)
}

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







|





|






|






|




|




|

|




|




|


|
>




|
|




|




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
	return [[[self alloc] init] autorelease];
}

- init
{
	self = [super init];

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

	_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)setName: (OFString*)name
{
	OF_SETTER(_name, name, YES, 1)
}

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