ObjFW  Check-in [f5515b0a1f]

Overview
Comment:Throw an exception when trying to deallocate a locked mutex.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f5515b0a1fd06d981ca4c78c0d70dd1f456c65da9155c40241f494a4919d2378
User & Date: js on 2011-03-07 13:43:41
Other Links: manifest | tags
Context
2011-03-07
15:39
Add abstraction for conditions. check-in: f771ddda2d user: js tags: trunk
13:43
Throw an exception when trying to deallocate a locked mutex. check-in: f5515b0a1f user: js tags: trunk
2011-02-27
14:40
OFPlugin: Don't close the handle before calling [super dealloc]. check-in: 9b88ee6978 user: js tags: trunk
Changes

Modified src/OFExceptions.h from [7ada383252] to [40dbf508af].

1168
1169
1170
1171
1172
1173
1174






1175
1176
1177
1178
1179
1180
1181

/**
 * \brief An exception indicating that unlocking a mutex failed.
 */
@interface OFMutexUnlockFailedException: OFException
@end







/**
 * \brief An exception indicating that the hash has already been calculated.
 */
@interface OFHashAlreadyCalculatedException: OFException
@end

/**







>
>
>
>
>
>







1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187

/**
 * \brief An exception indicating that unlocking a mutex failed.
 */
@interface OFMutexUnlockFailedException: OFException
@end

/**
 * \brief An exception indicating that a mutex is still locked.
 */
@interface OFMutexLockedException: OFException
@end

/**
 * \brief An exception indicating that the hash has already been calculated.
 */
@interface OFHashAlreadyCalculatedException: OFException
@end

/**

Modified src/OFExceptions.m from [744b7f16c3] to [4e6767989a].

1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704

1705













1706
1707
1708
1709
1710
1711
1712
- (OFString*)description
{
	if (description != nil)
		return description;

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

	return description;
}
@end

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

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

	return description;
}
@end

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

	description = [[OFString alloc] initWithFormat:

	    @"A mutex could not be unlocked in class %@", inClass];














	return description;
}
@end

@implementation OFHashAlreadyCalculatedException
- (OFString*)description







|












|












>
|
>
>
>
>
>
>
>
>
>
>
>
>
>







1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
- (OFString*)description
{
	if (description != nil)
		return description;

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

	return description;
}
@end

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

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

	return description;
}
@end

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

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

	return description;
}
@end

@implementation OFMutexLockedException
- (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;
}
@end

@implementation OFHashAlreadyCalculatedException
- (OFString*)description

Modified src/OFThread.m from [d347670acc] to [e256511cbe].

365
366
367
368
369
370
371
372

373
374
375
376
	if (!of_mutex_unlock(&mutex))
		@throw [OFMutexUnlockFailedException newWithClass: isa];
}

- (void)dealloc
{
	if (initialized)
		of_mutex_free(&mutex);


	[super dealloc];
}
@end







|
>




365
366
367
368
369
370
371
372
373
374
375
376
377
	if (!of_mutex_unlock(&mutex))
		@throw [OFMutexUnlockFailedException newWithClass: isa];
}

- (void)dealloc
{
	if (initialized)
		if (!of_mutex_free(&mutex))
			@throw [OFMutexLockedException newWithClass: isa];

	[super dealloc];
}
@end