Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -40,14 +40,14 @@ #import "OFString.h" #import "OFSystemInfo.h" #import "OFThread+Private.h" #import "OFThread.h" +#import "OFActivateSandboxFailedException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" -#import "OFSandboxActivationFailedException.h" #if defined(OF_MACOS) # include #elif defined(OF_WINDOWS) # include @@ -652,11 +652,11 @@ sandbox->_unveiledPathsIndex = unveiledPathsCount; promises = [sandbox.pledgeString cStringWithEncoding: encoding]; if (pledge(promises, NULL) != 0) - @throw [OFSandboxActivationFailedException + @throw [OFActivateSandboxFailedException exceptionWithSandbox: sandbox errNo: errno]; objc_autoreleasePoolPop(pool); @@ -680,11 +680,11 @@ promises = [sandbox.pledgeString cStringWithEncoding: [OFLocale encoding]]; if (pledge(NULL, promises) != 0) - @throw [OFSandboxActivationFailedException + @throw [OFActivateSandboxFailedException exceptionWithSandbox: sandbox errNo: errno]; objc_autoreleasePoolPop(pool); Index: src/OFCondition.h ================================================================== --- src/OFCondition.h +++ src/OFCondition.h @@ -44,11 +44,11 @@ * @ref broadcast. * * @note Waiting might have been interrupted by a signal. It is thus recommended * to check the condition again after @ref wait returned! * - * @throw OFConditionWaitFailedException Waiting for the condition failed + * @throw OFWaitForConditionFailedException Waiting for the condition failed */ - (void)wait; #ifdef OF_AMIGAOS /** @@ -57,11 +57,11 @@ * * @note This is only available on AmigaOS! * * @param signalMask A pointer to a signal mask of Exec Signals to receive. * This is modified and set to the mask of signals received. - * @throw OFConditionWaitFailedException Waiting for the condition failed + * @throw OFWaitForConditionFailedException Waiting for the condition failed */ - (void)waitForConditionOrExecSignal: (ULONG *)signalMask; #endif /** @@ -71,11 +71,11 @@ * @note Waiting might have been interrupted by a signal. It is thus recommended * to check the condition again after @ref waitForTimeInterval: returned! * * @param timeInterval The time interval until the timeout is reached * @return Whether the condition has been signaled - * @throw OFConditionWaitFailedException Waiting for the condition failed + * @throw OFWaitForConditionFailedException Waiting for the condition failed */ - (bool)waitForTimeInterval: (OFTimeInterval)timeInterval; #ifdef OF_AMIGAOS /** @@ -86,11 +86,11 @@ * * @param timeInterval The time interval until the timeout is reached * @param signalMask A pointer to a signal mask of Exec Signals to receive. * This is modified and set to the mask of signals received. * @return Whether the condition has been signaled or a signal received - * @throw OFConditionWaitFailedException Waiting for the condition failed + * @throw OFWaitForConditionFailedException Waiting for the condition failed */ - (bool)waitForTimeInterval: (OFTimeInterval)timeInterval orExecSignal: (ULONG *)signalMask; #endif @@ -101,11 +101,11 @@ * @note Waiting might have been interrupted by a signal. It is thus recommended * to check the condition again after @ref waitUntilDate: returned! * * @param date The date at which the timeout is reached * @return Whether the condition has been signaled - * @throw OFConditionWaitFailedException Waiting for the condition failed + * @throw OFWaitForConditionFailedException Waiting for the condition failed */ - (bool)waitUntilDate: (OFDate *)date; #ifdef OF_AMIGAOS /** @@ -116,26 +116,26 @@ * * @param date The date at which the timeout is reached * @param signalMask A pointer to a signal mask of Exec Signals to receive. * This is modified and set to the mask of signals received. * @return Whether the condition has been signaled or a signal received - * @throw OFConditionWaitFailedException Waiting for the condition failed + * @throw OFWaitForConditionFailedException Waiting for the condition failed */ - (bool)waitUntilDate: (OFDate *)date orExecSignal: (ULONG *)signalMask; #endif /** * @brief Signals the next waiting thread to continue. * - * @throw OFConditionSignalFailedException Signaling the condition failed + * @throw OFSignalConditionFailedException Signaling the condition failed */ - (void)signal; /** * @brief Signals all threads to continue. * - * @throw OFConditionBroadcastFailedException Broadcasting the condition failed + * @throw OFBroadcastConditionFailedException Broadcasting the condition failed */ - (void)broadcast; @end OF_ASSUME_NONNULL_END Index: src/OFCondition.m ================================================================== --- src/OFCondition.m +++ src/OFCondition.m @@ -18,15 +18,15 @@ #include #import "OFCondition.h" #import "OFDate.h" -#import "OFConditionBroadcastFailedException.h" -#import "OFConditionSignalFailedException.h" +#import "OFBroadcastConditionFailedException.h" #import "OFConditionStillWaitingException.h" -#import "OFConditionWaitFailedException.h" #import "OFInitializationFailedException.h" +#import "OFSignalConditionFailedException.h" +#import "OFWaitForConditionFailedException.h" @implementation OFCondition + (instancetype)condition { return [[[self alloc] init] autorelease]; @@ -66,11 +66,11 @@ - (void)wait { int error = OFPlainConditionWait(&_condition, &_mutex); if (error != 0) - @throw [OFConditionWaitFailedException + @throw [OFWaitForConditionFailedException exceptionWithCondition: self errNo: error]; } #ifdef OF_AMIGAOS @@ -78,11 +78,11 @@ { int error = OFPlainConditionWaitOrExecSignal(&_condition, &_mutex, signalMask); if (error != 0) - @throw [OFConditionWaitFailedException + @throw [OFWaitForConditionFailedException exceptionWithCondition: self errNo: error]; } #endif @@ -93,11 +93,11 @@ if (error == ETIMEDOUT) return false; if (error != 0) - @throw [OFConditionWaitFailedException + @throw [OFWaitForConditionFailedException exceptionWithCondition: self errNo: error]; return true; } @@ -111,11 +111,11 @@ if (error == ETIMEDOUT) return false; if (error != 0) - @throw [OFConditionWaitFailedException + @throw [OFWaitForConditionFailedException exceptionWithCondition: self errNo: error]; return true; } @@ -137,20 +137,20 @@ - (void)signal { int error = OFPlainConditionSignal(&_condition); if (error != 0) - @throw [OFConditionSignalFailedException + @throw [OFSignalConditionFailedException exceptionWithCondition: self errNo: error]; } - (void)broadcast { int error = OFPlainConditionBroadcast(&_condition); if (error != 0) - @throw [OFConditionBroadcastFailedException + @throw [OFBroadcastConditionFailedException exceptionWithCondition: self errNo: error]; } @end Index: src/OFThread.h ================================================================== --- src/OFThread.h +++ src/OFThread.h @@ -300,23 +300,23 @@ - (void)handleTermination OF_REQUIRES_SUPER; /** * @brief Starts the thread. * + * @throw OFStartThreadFailedException Starting the thread failed * @throw OFThreadStillRunningException The thread is still running - * @throw OFThreadStartFailedException Starting the thread failed */ - (void)start; /** * @brief Joins a thread. * * @return The object returned by the main method of the thread. - * @throw OFThreadJoinFailedException Joining the thread failed + * @throw OFJoinThreadFailedException Joining the thread failed */ - (id)join; #else - (instancetype)init OF_UNAVAILABLE; #endif @end OF_ASSUME_NONNULL_END Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -73,12 +73,12 @@ #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFNotImplementedException.h" #import "OFOutOfRangeException.h" #ifdef OF_HAVE_THREADS -# import "OFThreadJoinFailedException.h" -# import "OFThreadStartFailedException.h" +# import "OFJoinThreadFailedException.h" +# import "OFStartThreadFailedException.h" # import "OFThreadStillRunningException.h" #endif #ifdef OF_MINT /* freemint-gcc does not have trunc() */ @@ -435,11 +435,11 @@ _running = OFThreadStateRunning; if ((error = OFPlainThreadNew(&_thread, [_name cStringWithEncoding: [OFLocale encoding]], callMain, self, &_attr)) != 0) { [self release]; - @throw [OFThreadStartFailedException + @throw [OFStartThreadFailedException exceptionWithThread: self errNo: error]; } } @@ -446,16 +446,16 @@ - (id)join { int error; if (_running == OFThreadStateNotRunning) - @throw [OFThreadJoinFailedException + @throw [OFJoinThreadFailedException exceptionWithThread: self errNo: EINVAL]; if ((error = OFPlainThreadJoin(_thread)) != 0) - @throw [OFThreadJoinFailedException exceptionWithThread: self + @throw [OFJoinThreadFailedException exceptionWithThread: self errNo: error]; _running = OFThreadStateNotRunning; return _returnValue; Index: src/ObjFW.h ================================================================== --- src/ObjFW.h +++ src/ObjFW.h @@ -142,131 +142,102 @@ # import "OFWindowsRegistryKey.h" #endif #import "OFAllocFailedException.h" #import "OFException.h" -#ifdef OF_HAVE_SOCKETS -# import "OFAcceptSocketFailedException.h" -# import "OFAlreadyConnectedException.h" -# import "OFBindSocketFailedException.h" -# import "OFBindIPSocketFailedException.h" -# ifdef OF_HAVE_UNIX_SOCKETS -# import "OFBindUNIXSocketFailedException.h" -# endif -# ifdef OF_HAVE_IPX -# import "OFBindIPXSocketFailedException.h" -# endif -# ifdef OF_HAVE_APPLETALK -# import "OFBindDDPSocketFailedException.h" -# endif -#endif #import "OFChangeCurrentDirectoryFailedException.h" #import "OFChecksumMismatchException.h" -#ifdef OF_HAVE_THREADS -# import "OFConditionBroadcastFailedException.h" -# import "OFConditionSignalFailedException.h" -# import "OFConditionStillWaitingException.h" -# import "OFConditionWaitFailedException.h" -#endif -#ifdef OF_HAVE_SOCKETS -# import "OFConnectSocketFailedException.h" -# import "OFConnectIPSocketFailedException.h" -# ifdef OF_HAVE_UNIX_SOCKETS -# import "OFConnectUNIXSocketFailedException.h" -# endif -# ifdef OF_HAVE_IPX -# import "OFConnectSPXSocketFailedException.h" -# endif -#endif #import "OFCopyItemFailedException.h" #import "OFCreateDirectoryFailedException.h" #import "OFCreateSymbolicLinkFailedException.h" -#ifdef OF_WINDOWS -# import "OFCreateWindowsRegistryKeyFailedException.h" -#endif -#ifdef OF_HAVE_SOCKETS -# import "OFDNSQueryFailedException.h" -#endif -#ifdef OF_WINDOWS -# import "OFDeleteWindowsRegistryKeyFailedException.h" -# import "OFDeleteWindowsRegistryValueFailedException.h" -#endif #import "OFEnumerationMutationException.h" #ifdef OF_HAVE_FILES # import "OFGetCurrentDirectoryFailedException.h" #endif #import "OFGetItemAttributesFailedException.h" #import "OFGetOptionFailedException.h" -#ifdef OF_WINDOWS -# import "OFGetWindowsRegistryValueFailedException.h" -#endif #import "OFHashAlreadyCalculatedException.h" #import "OFHashNotCalculatedException.h" -#ifdef OF_HAVE_SOCKETS -# import "OFHTTPRequestFailedException.h" -#endif #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidEncodingException.h" #import "OFInvalidFormatException.h" #import "OFInvalidJSONException.h" #import "OFInvalidServerResponseException.h" #import "OFLinkItemFailedException.h" -#ifdef OF_HAVE_SOCKETS -# import "OFListenOnSocketFailedException.h" -#endif #ifdef OF_HAVE_PLUGINS # import "OFLoadPluginFailedException.h" #endif #import "OFLockFailedException.h" #import "OFMalformedXMLException.h" #import "OFMoveItemFailedException.h" #import "OFNotImplementedException.h" #import "OFNotOpenException.h" -#ifdef OF_HAVE_SOCKETS -# import "OFObserveKernelEventsFailedException.h" -#endif #import "OFOpenItemFailedException.h" -#ifdef OF_WINDOWS -# import "OFOpenWindowsRegistryKeyFailedException.h" -#endif #import "OFOutOfMemoryException.h" #import "OFOutOfRangeException.h" #import "OFReadFailedException.h" #import "OFReadOrWriteFailedException.h" #import "OFRemoveItemFailedException.h" -#ifdef OF_HAVE_SOCKETS -# import "OFResolveHostFailedException.h" -#endif #import "OFSeekFailedException.h" #import "OFSetItemAttributesFailedException.h" #import "OFSetOptionFailedException.h" -#ifdef OF_WINDOWS -# import "OFSetWindowsRegistryValueFailedException.h" -#endif #import "OFStillLockedException.h" -#ifdef OF_HAVE_THREADS -# import "OFThreadJoinFailedException.h" -# import "OFThreadStartFailedException.h" -# import "OFThreadStillRunningException.h" -#endif -#ifdef OF_HAVE_SOCKETS -# import "OFTLSHandshakeFailedException.h" -#endif #import "OFTruncatedDataException.h" #import "OFUnboundNamespaceException.h" #import "OFUnboundPrefixException.h" #import "OFUndefinedKeyException.h" #import "OFUnknownXMLEntityException.h" #import "OFUnlockFailedException.h" #import "OFUnsupportedProtocolException.h" #import "OFUnsupportedVersionException.h" #import "OFWriteFailedException.h" - +#ifdef OF_HAVE_SOCKETS +# import "OFAcceptSocketFailedException.h" +# import "OFAlreadyConnectedException.h" +# import "OFBindIPSocketFailedException.h" +# import "OFBindSocketFailedException.h" +# import "OFConnectIPSocketFailedException.h" +# import "OFConnectSocketFailedException.h" +# import "OFDNSQueryFailedException.h" +# import "OFHTTPRequestFailedException.h" +# import "OFListenOnSocketFailedException.h" +# import "OFObserveKernelEventsFailedException.h" +# import "OFResolveHostFailedException.h" +# import "OFTLSHandshakeFailedException.h" +# ifdef OF_HAVE_UNIX_SOCKETS +# import "OFBindUNIXSocketFailedException.h" +# import "OFConnectUNIXSocketFailedException.h" +# endif +# ifdef OF_HAVE_IPX +# import "OFBindIPXSocketFailedException.h" +# import "OFConnectSPXSocketFailedException.h" +# endif +# ifdef OF_HAVE_APPLETALK +# import "OFBindDDPSocketFailedException.h" +# endif +#endif +#ifdef OF_HAVE_THREADS +# import "OFBroadcastConditionFailedException.h" +# import "OFConditionStillWaitingException.h" +# import "OFJoinThreadFailedException.h" +# import "OFSignalConditionFailedException.h" +# import "OFStartThreadFailedException.h" +# import "OFThreadStillRunningException.h" +# import "OFWaitForConditionFailedException.h" +#endif #ifdef OF_HAVE_PLUGINS # import "OFPlugin.h" #endif +#ifdef OF_WINDOWS +# import "OFCreateWindowsRegistryKeyFailedException.h" +# import "OFDeleteWindowsRegistryKeyFailedException.h" +# import "OFDeleteWindowsRegistryValueFailedException.h" +# import "OFGetWindowsRegistryValueFailedException.h" +# import "OFOpenWindowsRegistryKeyFailedException.h" +# import "OFSetWindowsRegistryValueFailedException.h" +#endif #ifdef OF_HAVE_ATOMIC_OPS # import "OFAtomic.h" #endif #import "OFLocking.h" Index: src/exceptions/Makefile ================================================================== --- src/exceptions/Makefile +++ src/exceptions/Makefile @@ -71,26 +71,26 @@ SRCS_APPLETALK = OFBindDDPSocketFailedException.m SRCS_IPX = OFBindIPXSocketFailedException.m \ OFConnectSPXSocketFailedException.m SRCS_UNIX_SOCKETS = OFBindUNIXSocketFailedException.m \ OFConnectUNIXSocketFailedException.m -SRCS_THREADS = OFConditionBroadcastFailedException.m \ - OFConditionSignalFailedException.m \ +SRCS_THREADS = OFBroadcastConditionFailedException.m \ OFConditionStillWaitingException.m \ - OFConditionWaitFailedException.m \ - OFThreadJoinFailedException.m \ - OFThreadStartFailedException.m \ - OFThreadStillRunningException.m + OFJoinThreadFailedException.m \ + OFSignalConditionFailedException.m \ + OFStartThreadFailedException.m \ + OFThreadStillRunningException.m \ + OFWaitForConditionFailedException.m SRCS_WINDOWS = OFCreateWindowsRegistryKeyFailedException.m \ OFDeleteWindowsRegistryKeyFailedException.m \ OFDeleteWindowsRegistryValueFailedException.m \ OFGetWindowsRegistryValueFailedException.m \ OFOpenWindowsRegistryKeyFailedException.m \ OFSetWindowsRegistryValueFailedException.m INCLUDES := ${SRCS:.m=.h} -SRCS += OFSandboxActivationFailedException.m +SRCS += OFActivateSandboxFailedException.m include ../../buildsys.mk CPPFLAGS += -I. -I.. -I../.. -I../runtime ADDED src/exceptions/OFActivateSandboxFailedException.h Index: src/exceptions/OFActivateSandboxFailedException.h ================================================================== --- src/exceptions/OFActivateSandboxFailedException.h +++ src/exceptions/OFActivateSandboxFailedException.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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" + +OF_ASSUME_NONNULL_BEGIN + +@class OFSandbox; + +@interface OFActivateSandboxFailedException: OFException +{ + OFSandbox *_sandbox; + int _errNo; +} + +@property (readonly, nonatomic) OFSandbox *sandbox; +@property (readonly, nonatomic) int errNo; + ++ (instancetype)exception OF_UNAVAILABLE; ++ (instancetype)exceptionWithSandbox: (OFSandbox *)sandbox errNo: (int)errNo; +- (instancetype)init OF_UNAVAILABLE; +- (instancetype)initWithSandbox: (OFSandbox *)sandbox + errNo: (int)errNo OF_DESIGNATED_INITIALIZER; +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/OFActivateSandboxFailedException.m Index: src/exceptions/OFActivateSandboxFailedException.m ================================================================== --- src/exceptions/OFActivateSandboxFailedException.m +++ src/exceptions/OFActivateSandboxFailedException.m @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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 "OFActivateSandboxFailedException.h" +#import "OFString.h" +#import "OFSandbox.h" + +@implementation OFActivateSandboxFailedException +@synthesize sandbox = _sandbox, errNo = _errNo; + ++ (instancetype)exception +{ + OF_UNRECOGNIZED_SELECTOR +} + ++ (instancetype)exceptionWithSandbox: (OFSandbox *)sandbox errNo: (int)errNo +{ + return [[[self alloc] initWithSandbox: sandbox + errNo: errNo] autorelease]; +} + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} + +- (instancetype)initWithSandbox: (OFSandbox *)sandbox errNo: (int)errNo +{ + self = [super init]; + + _sandbox = [sandbox retain]; + _errNo = errNo; + + return self; +} + +- (void)dealloc +{ + [_sandbox release]; + + [super dealloc]; +} + +- (OFString *)description +{ + return [OFString stringWithFormat: + @"The sandbox could not be applied: %@", OFStrError(_errNo)]; +} +@end ADDED src/exceptions/OFBroadcastConditionFailedException.h Index: src/exceptions/OFBroadcastConditionFailedException.h ================================================================== --- src/exceptions/OFBroadcastConditionFailedException.h +++ src/exceptions/OFBroadcastConditionFailedException.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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" + +#ifndef OF_HAVE_THREADS +# error No threads available! +#endif + +OF_ASSUME_NONNULL_BEGIN + +@class OFCondition; + +/** + * @class OFBroadcastConditionFailedException \ + * OFBroadcastConditionFailedException.h \ + * ObjFW/OFBroadcastConditionFailedException.h + * + * @brief An exception indicating broadcasting a condition failed. + */ +@interface OFBroadcastConditionFailedException: OFException +{ + OFCondition *_condition; + int _errNo; + OF_RESERVE_IVARS(OFBroadcastConditionFailedException, 4) +} + +/** + * @brief The condition which could not be broadcasted. + */ +@property (readonly, nonatomic) OFCondition *condition; + +/** + * @brief The errno of the error that occurred. + */ +@property (readonly, nonatomic) int errNo; + +/** + * @brief Returns a new, autoreleased condition broadcast failed exception. + * + * @param condition The condition which could not be broadcasted + * @param errNo The errno of the error that occurred + * @return A new, autoreleased condition broadcast failed exception + */ ++ (instancetype)exceptionWithCondition: (OFCondition *)condition + errNo: (int)errNo; + ++ (instancetype)exception OF_UNAVAILABLE; + +/** + * @brief Initializes an already allocated condition broadcast failed exception. + * + * @param condition The condition which could not be broadcasted + * @param errNo The errno of the error that occurred + * @return An initialized condition broadcast failed exception + */ +- (instancetype)initWithCondition: (OFCondition *)condition + errNo: (int)errNo OF_DESIGNATED_INITIALIZER; + +- (instancetype)init OF_UNAVAILABLE; +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/OFBroadcastConditionFailedException.m Index: src/exceptions/OFBroadcastConditionFailedException.m ================================================================== --- src/exceptions/OFBroadcastConditionFailedException.m +++ src/exceptions/OFBroadcastConditionFailedException.m @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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" + +#include + +#import "OFBroadcastConditionFailedException.h" +#import "OFString.h" +#import "OFCondition.h" + +@implementation OFBroadcastConditionFailedException +@synthesize condition = _condition, errNo = _errNo; + ++ (instancetype)exceptionWithCondition: (OFCondition *)condition + errNo: (int)errNo +{ + return [[[self alloc] initWithCondition: condition + errNo: errNo] autorelease]; +} + ++ (instancetype)exception +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (instancetype)initWithCondition: (OFCondition *)condition errNo: (int)errNo +{ + self = [super init]; + + _condition = [condition retain]; + _errNo = errNo; + + return self; +} + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} + +- (void)dealloc +{ + [_condition release]; + + [super dealloc]; +} + +- (OFString *)description +{ + return [OFString stringWithFormat: + @"Broadcasting a condition of type %@ failed: %s", + _condition.class, strerror(_errNo)]; +} +@end DELETED src/exceptions/OFConditionBroadcastFailedException.h Index: src/exceptions/OFConditionBroadcastFailedException.h ================================================================== --- src/exceptions/OFConditionBroadcastFailedException.h +++ src/exceptions/OFConditionBroadcastFailedException.h @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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" - -#ifndef OF_HAVE_THREADS -# error No threads available! -#endif - -OF_ASSUME_NONNULL_BEGIN - -@class OFCondition; - -/** - * @class OFConditionBroadcastFailedException \ - * OFConditionBroadcastFailedException.h \ - * ObjFW/OFConditionBroadcastFailedException.h - * - * @brief An exception indicating broadcasting a condition failed. - */ -@interface OFConditionBroadcastFailedException: OFException -{ - OFCondition *_condition; - int _errNo; - OF_RESERVE_IVARS(OFConditionBroadcastFailedException, 4) -} - -/** - * @brief The condition which could not be broadcasted. - */ -@property (readonly, nonatomic) OFCondition *condition; - -/** - * @brief The errno of the error that occurred. - */ -@property (readonly, nonatomic) int errNo; - -/** - * @brief Returns a new, autoreleased condition broadcast failed exception. - * - * @param condition The condition which could not be broadcasted - * @param errNo The errno of the error that occurred - * @return A new, autoreleased condition broadcast failed exception - */ -+ (instancetype)exceptionWithCondition: (OFCondition *)condition - errNo: (int)errNo; - -+ (instancetype)exception OF_UNAVAILABLE; - -/** - * @brief Initializes an already allocated condition broadcast failed exception. - * - * @param condition The condition which could not be broadcasted - * @param errNo The errno of the error that occurred - * @return An initialized condition broadcast failed exception - */ -- (instancetype)initWithCondition: (OFCondition *)condition - errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - -- (instancetype)init OF_UNAVAILABLE; -@end - -OF_ASSUME_NONNULL_END DELETED src/exceptions/OFConditionBroadcastFailedException.m Index: src/exceptions/OFConditionBroadcastFailedException.m ================================================================== --- src/exceptions/OFConditionBroadcastFailedException.m +++ src/exceptions/OFConditionBroadcastFailedException.m @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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" - -#include - -#import "OFConditionBroadcastFailedException.h" -#import "OFString.h" -#import "OFCondition.h" - -@implementation OFConditionBroadcastFailedException -@synthesize condition = _condition, errNo = _errNo; - -+ (instancetype)exceptionWithCondition: (OFCondition *)condition - errNo: (int)errNo -{ - return [[[self alloc] initWithCondition: condition - errNo: errNo] autorelease]; -} - -+ (instancetype)exception -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (instancetype)initWithCondition: (OFCondition *)condition errNo: (int)errNo -{ - self = [super init]; - - _condition = [condition retain]; - _errNo = errNo; - - return self; -} - -- (instancetype)init -{ - OF_INVALID_INIT_METHOD -} - -- (void)dealloc -{ - [_condition release]; - - [super dealloc]; -} - -- (OFString *)description -{ - return [OFString stringWithFormat: - @"Broadcasting a condition of type %@ failed: %s", - _condition.class, strerror(_errNo)]; -} -@end DELETED src/exceptions/OFConditionSignalFailedException.h Index: src/exceptions/OFConditionSignalFailedException.h ================================================================== --- src/exceptions/OFConditionSignalFailedException.h +++ src/exceptions/OFConditionSignalFailedException.h @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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" - -#ifndef OF_HAVE_THREADS -# error No threads available! -#endif - -OF_ASSUME_NONNULL_BEGIN - -@class OFCondition; - -/** - * @class OFConditionSignalFailedException \ - * OFConditionSignalFailedException.h \ - * ObjFW/OFConditionSignalFailedException.h - * - * @brief An exception indicating signaling a condition failed. - */ -@interface OFConditionSignalFailedException: OFException -{ - OFCondition *_condition; - int _errNo; - OF_RESERVE_IVARS(OFConditionSignalFailedException, 4) -} - -/** - * @brief The condition which could not be signaled. - */ -@property (readonly, nonatomic) OFCondition *condition; - -/** - * @brief The errno of the error that occurred. - */ -@property (readonly, nonatomic) int errNo; - -/** - * @brief Creates a new, autoreleased condition signal failed exception. - * - * @param condition The condition which could not be signaled - * @param errNo The errno of the error that occurred - * @return A new, autoreleased condition signal failed exception - */ -+ (instancetype)exceptionWithCondition: (OFCondition *)condition - errNo: (int)errNo; - -+ (instancetype)exception OF_UNAVAILABLE; - -/** - * @brief Initializes an already allocated condition signal failed exception. - * - * @param condition The condition which could not be signaled - * @param errNo The errno of the error that occurred - * @return An initialized condition signal failed exception - */ -- (instancetype)initWithCondition: (OFCondition *)condition - errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - -- (instancetype)init OF_UNAVAILABLE; -@end - -OF_ASSUME_NONNULL_END DELETED src/exceptions/OFConditionSignalFailedException.m Index: src/exceptions/OFConditionSignalFailedException.m ================================================================== --- src/exceptions/OFConditionSignalFailedException.m +++ src/exceptions/OFConditionSignalFailedException.m @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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" - -#include - -#import "OFConditionSignalFailedException.h" -#import "OFString.h" -#import "OFCondition.h" - -@implementation OFConditionSignalFailedException -@synthesize condition = _condition, errNo = _errNo; - -+ (instancetype)exceptionWithCondition: (OFCondition *)condition - errNo: (int)errNo -{ - return [[[self alloc] initWithCondition: condition - errNo: errNo] autorelease]; -} - -+ (instancetype)exception -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (instancetype)initWithCondition: (OFCondition *)condition errNo: (int)errNo -{ - self = [super init]; - - _condition = [condition retain]; - _errNo = errNo; - - return self; -} - -- (instancetype)init -{ - OF_INVALID_INIT_METHOD -} - -- (void)dealloc -{ - [_condition release]; - - [super dealloc]; -} - -- (OFString *)description -{ - return [OFString stringWithFormat: - @"Signaling a condition of type %@ failed: %s", - _condition.class, strerror(_errNo)]; -} -@end DELETED src/exceptions/OFConditionWaitFailedException.h Index: src/exceptions/OFConditionWaitFailedException.h ================================================================== --- src/exceptions/OFConditionWaitFailedException.h +++ src/exceptions/OFConditionWaitFailedException.h @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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" - -#ifndef OF_HAVE_THREADS -# error No threads available! -#endif - -OF_ASSUME_NONNULL_BEGIN - -@class OFCondition; - -/** - * @class OFConditionWaitFailedException \ - * OFConditionWaitFailedException.h \ - * ObjFW/OFConditionWaitFailedException.h - * - * @brief An exception indicating waiting for a condition failed. - */ -@interface OFConditionWaitFailedException: OFException -{ - OFCondition *_condition; - int _errNo; - OF_RESERVE_IVARS(OFConditionWaitFailedException, 4) -} - -/** - * @brief The condition for which could not be waited. - */ -@property (readonly, nonatomic) OFCondition *condition; - -/** - * @brief The errno of the error that occurred. - */ -@property (readonly, nonatomic) int errNo; - -/** - * @brief Creates a new, autoreleased condition wait failed exception. - * - * @param condition The condition for which could not be waited - * @param errNo The errno of the error that occurred - * @return A new, autoreleased condition wait failed exception - */ -+ (instancetype)exceptionWithCondition: (OFCondition *)condition - errNo: (int)errNo; - -+ (instancetype)exception OF_UNAVAILABLE; - -/** - * @brief Initializes an already allocated condition wait failed exception. - * - * @param condition The condition for which could not be waited - * @param errNo The errno of the error that occurred - * @return An initialized condition wait failed exception - */ -- (instancetype)initWithCondition: (OFCondition *)condition - errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - -- (instancetype)init OF_UNAVAILABLE; -@end - -OF_ASSUME_NONNULL_END DELETED src/exceptions/OFConditionWaitFailedException.m Index: src/exceptions/OFConditionWaitFailedException.m ================================================================== --- src/exceptions/OFConditionWaitFailedException.m +++ src/exceptions/OFConditionWaitFailedException.m @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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" - -#include - -#import "OFConditionWaitFailedException.h" -#import "OFString.h" -#import "OFCondition.h" - -@implementation OFConditionWaitFailedException -@synthesize condition = _condition, errNo = _errNo; - -+ (instancetype)exceptionWithCondition: (OFCondition *)condition - errNo: (int)errNo -{ - return [[[self alloc] initWithCondition: condition - errNo: errNo] autorelease]; -} - -+ (instancetype)exception -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (instancetype)initWithCondition: (OFCondition *)condition errNo: (int)errNo -{ - self = [super init]; - - _condition = [condition retain]; - _errNo = errNo; - - return self; -} - -- (instancetype)init -{ - OF_INVALID_INIT_METHOD -} - -- (void)dealloc -{ - [_condition release]; - - [super dealloc]; -} - -- (OFString *)description -{ - return [OFString stringWithFormat: - @"Waiting for a condition of type %@ failed: %s", - _condition.class, strerror(_errNo)]; -} -@end ADDED src/exceptions/OFJoinThreadFailedException.h Index: src/exceptions/OFJoinThreadFailedException.h ================================================================== --- src/exceptions/OFJoinThreadFailedException.h +++ src/exceptions/OFJoinThreadFailedException.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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" + +#ifndef OF_HAVE_THREADS +# error No threads available! +#endif + +OF_ASSUME_NONNULL_BEGIN + +@class OFThread; + +/** + * @class OFJoinThreadFailedException \ + * OFJoinThreadFailedException.h ObjFW/OFJoinThreadFailedException.h + * + * @brief An exception indicating that joining a thread failed. + */ +@interface OFJoinThreadFailedException: OFException +{ + OFThread *_Nullable _thread; + int _errNo; + OF_RESERVE_IVARS(OFJoinThreadFailedException, 4) +} + +/** + * @brief The thread which could not be joined. + */ +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFThread *thread; + +/** + * @brief The errno of the error that occurred. + */ +@property (readonly, nonatomic) int errNo; + +/** + * @brief Creates a new, autoreleased thread join failed exception. + * + * @param thread The thread which could not be joined + * @param errNo The errno of the error that occurred + * @return A new, autoreleased thread join failed exception + */ ++ (instancetype)exceptionWithThread: (nullable OFThread *)thread + errNo: (int)errNo; + ++ (instancetype)exception OF_UNAVAILABLE; + +/** + * @brief Initializes an already allocated thread join failed exception. + * + * @param thread The thread which could not be joined + * @param errNo The errno of the error that occurred + * @return An initialized thread join failed exception + */ +- (instancetype)initWithThread: (nullable OFThread *)thread + errNo: (int)errNo OF_DESIGNATED_INITIALIZER; + +- (instancetype)init OF_UNAVAILABLE; +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/OFJoinThreadFailedException.m Index: src/exceptions/OFJoinThreadFailedException.m ================================================================== --- src/exceptions/OFJoinThreadFailedException.m +++ src/exceptions/OFJoinThreadFailedException.m @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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" + +#include + +#import "OFJoinThreadFailedException.h" +#import "OFString.h" +#import "OFThread.h" + +@implementation OFJoinThreadFailedException +@synthesize thread = _thread, errNo = _errNo; + ++ (instancetype)exceptionWithThread: (OFThread *)thread errNo: (int)errNo +{ + return [[[self alloc] initWithThread: thread errNo: errNo] autorelease]; +} + ++ (instancetype)exception +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (instancetype)initWithThread: (OFThread *)thread errNo: (int)errNo +{ + self = [super init]; + + _thread = [thread retain]; + _errNo = errNo; + + return self; +} + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} + +- (void)dealloc +{ + [_thread release]; + + [super dealloc]; +} + +- (OFString *)description +{ + return [OFString stringWithFormat: + @"Joining a thread of type %@ failed: %s", + _thread.class, strerror(_errNo)]; +} +@end DELETED src/exceptions/OFSandboxActivationFailedException.h Index: src/exceptions/OFSandboxActivationFailedException.h ================================================================== --- src/exceptions/OFSandboxActivationFailedException.h +++ src/exceptions/OFSandboxActivationFailedException.h @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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" - -OF_ASSUME_NONNULL_BEGIN - -@class OFSandbox; - -@interface OFSandboxActivationFailedException: OFException -{ - OFSandbox *_sandbox; - int _errNo; -} - -@property (readonly, nonatomic) OFSandbox *sandbox; -@property (readonly, nonatomic) int errNo; - -+ (instancetype)exception OF_UNAVAILABLE; -+ (instancetype)exceptionWithSandbox: (OFSandbox *)sandbox errNo: (int)errNo; -- (instancetype)init OF_UNAVAILABLE; -- (instancetype)initWithSandbox: (OFSandbox *)sandbox - errNo: (int)errNo OF_DESIGNATED_INITIALIZER; -@end - -OF_ASSUME_NONNULL_END DELETED src/exceptions/OFSandboxActivationFailedException.m Index: src/exceptions/OFSandboxActivationFailedException.m ================================================================== --- src/exceptions/OFSandboxActivationFailedException.m +++ src/exceptions/OFSandboxActivationFailedException.m @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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 "OFSandboxActivationFailedException.h" -#import "OFString.h" -#import "OFSandbox.h" - -@implementation OFSandboxActivationFailedException -@synthesize sandbox = _sandbox, errNo = _errNo; - -+ (instancetype)exception -{ - OF_UNRECOGNIZED_SELECTOR -} - -+ (instancetype)exceptionWithSandbox: (OFSandbox *)sandbox errNo: (int)errNo -{ - return [[[self alloc] initWithSandbox: sandbox - errNo: errNo] autorelease]; -} - -- (instancetype)init -{ - OF_INVALID_INIT_METHOD -} - -- (instancetype)initWithSandbox: (OFSandbox *)sandbox errNo: (int)errNo -{ - self = [super init]; - - _sandbox = [sandbox retain]; - _errNo = errNo; - - return self; -} - -- (void)dealloc -{ - [_sandbox release]; - - [super dealloc]; -} - -- (OFString *)description -{ - return [OFString stringWithFormat: - @"The sandbox could not be applied: %@", OFStrError(_errNo)]; -} -@end ADDED src/exceptions/OFSignalConditionFailedException.h Index: src/exceptions/OFSignalConditionFailedException.h ================================================================== --- src/exceptions/OFSignalConditionFailedException.h +++ src/exceptions/OFSignalConditionFailedException.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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" + +#ifndef OF_HAVE_THREADS +# error No threads available! +#endif + +OF_ASSUME_NONNULL_BEGIN + +@class OFCondition; + +/** + * @class OFSignalConditionFailedException \ + * OFSignalConditionFailedException.h \ + * ObjFW/OFSignalConditionFailedException.h + * + * @brief An exception indicating signaling a condition failed. + */ +@interface OFSignalConditionFailedException: OFException +{ + OFCondition *_condition; + int _errNo; + OF_RESERVE_IVARS(OFSignalConditionFailedException, 4) +} + +/** + * @brief The condition which could not be signaled. + */ +@property (readonly, nonatomic) OFCondition *condition; + +/** + * @brief The errno of the error that occurred. + */ +@property (readonly, nonatomic) int errNo; + +/** + * @brief Creates a new, autoreleased condition signal failed exception. + * + * @param condition The condition which could not be signaled + * @param errNo The errno of the error that occurred + * @return A new, autoreleased condition signal failed exception + */ ++ (instancetype)exceptionWithCondition: (OFCondition *)condition + errNo: (int)errNo; + ++ (instancetype)exception OF_UNAVAILABLE; + +/** + * @brief Initializes an already allocated condition signal failed exception. + * + * @param condition The condition which could not be signaled + * @param errNo The errno of the error that occurred + * @return An initialized condition signal failed exception + */ +- (instancetype)initWithCondition: (OFCondition *)condition + errNo: (int)errNo OF_DESIGNATED_INITIALIZER; + +- (instancetype)init OF_UNAVAILABLE; +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/OFSignalConditionFailedException.m Index: src/exceptions/OFSignalConditionFailedException.m ================================================================== --- src/exceptions/OFSignalConditionFailedException.m +++ src/exceptions/OFSignalConditionFailedException.m @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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" + +#include + +#import "OFSignalConditionFailedException.h" +#import "OFString.h" +#import "OFCondition.h" + +@implementation OFSignalConditionFailedException +@synthesize condition = _condition, errNo = _errNo; + ++ (instancetype)exceptionWithCondition: (OFCondition *)condition + errNo: (int)errNo +{ + return [[[self alloc] initWithCondition: condition + errNo: errNo] autorelease]; +} + ++ (instancetype)exception +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (instancetype)initWithCondition: (OFCondition *)condition errNo: (int)errNo +{ + self = [super init]; + + _condition = [condition retain]; + _errNo = errNo; + + return self; +} + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} + +- (void)dealloc +{ + [_condition release]; + + [super dealloc]; +} + +- (OFString *)description +{ + return [OFString stringWithFormat: + @"Signaling a condition of type %@ failed: %s", + _condition.class, strerror(_errNo)]; +} +@end ADDED src/exceptions/OFStartThreadFailedException.h Index: src/exceptions/OFStartThreadFailedException.h ================================================================== --- src/exceptions/OFStartThreadFailedException.h +++ src/exceptions/OFStartThreadFailedException.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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" + +#ifndef OF_HAVE_THREADS +# error No threads available! +#endif + +OF_ASSUME_NONNULL_BEGIN + +@class OFThread; + +/** + * @class OFStartThreadFailedException \ + * OFStartThreadFailedException.h ObjFW/OFStartThreadFailedException.h + * + * @brief An exception indicating that starting a thread failed. + */ +@interface OFStartThreadFailedException: OFException +{ + OFThread *_Nullable _thread; + int _errNo; + OF_RESERVE_IVARS(OFStartThreadFailedException, 4) +} + +/** + * @brief The thread which could not be started. + */ +@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFThread *thread; + +/** + * @brief The errno of the error that occurred. + */ +@property (readonly, nonatomic) int errNo; + +/** + * @brief Creates a new, autoreleased thread start failed exception. + * + * @param thread The thread which could not be started + * @param errNo The errno of the error that occurred + * @return A new, autoreleased thread start failed exception + */ ++ (instancetype)exceptionWithThread: (nullable OFThread *)thread + errNo: (int)errNo; + ++ (instancetype)exception OF_UNAVAILABLE; + +/** + * @brief Initializes an already allocated thread start failed exception. + * + * @param thread The thread which could not be started + * @param errNo The errno of the error that occurred + * @return An initialized thread start failed exception + */ +- (instancetype)initWithThread: (nullable OFThread *)thread + errNo: (int)errNo OF_DESIGNATED_INITIALIZER; + +- (instancetype)init OF_UNAVAILABLE; +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/OFStartThreadFailedException.m Index: src/exceptions/OFStartThreadFailedException.m ================================================================== --- src/exceptions/OFStartThreadFailedException.m +++ src/exceptions/OFStartThreadFailedException.m @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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" + +#include + +#import "OFStartThreadFailedException.h" +#import "OFString.h" +#import "OFThread.h" + +@implementation OFStartThreadFailedException +@synthesize thread = _thread, errNo = _errNo; + ++ (instancetype)exceptionWithThread: (OFThread *)thread errNo: (int)errNo +{ + return [[[self alloc] initWithThread: thread errNo: errNo] autorelease]; +} + ++ (instancetype)exception +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (instancetype)initWithThread: (OFThread *)thread errNo: (int)errNo +{ + self = [super init]; + + _thread = [thread retain]; + _errNo = errNo; + + return self; +} + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} + +- (void)dealloc +{ + [_thread release]; + + [super dealloc]; +} + +- (OFString *)description +{ + return [OFString stringWithFormat: + @"Starting a thread of type %@ failed: %s", + _thread.class, strerror(_errNo)]; +} +@end DELETED src/exceptions/OFThreadJoinFailedException.h Index: src/exceptions/OFThreadJoinFailedException.h ================================================================== --- src/exceptions/OFThreadJoinFailedException.h +++ src/exceptions/OFThreadJoinFailedException.h @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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" - -#ifndef OF_HAVE_THREADS -# error No threads available! -#endif - -OF_ASSUME_NONNULL_BEGIN - -@class OFThread; - -/** - * @class OFThreadJoinFailedException \ - * OFThreadJoinFailedException.h ObjFW/OFThreadJoinFailedException.h - * - * @brief An exception indicating that joining a thread failed. - */ -@interface OFThreadJoinFailedException: OFException -{ - OFThread *_Nullable _thread; - int _errNo; - OF_RESERVE_IVARS(OFThreadJoinFailedException, 4) -} - -/** - * @brief The thread which could not be joined. - */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFThread *thread; - -/** - * @brief The errno of the error that occurred. - */ -@property (readonly, nonatomic) int errNo; - -/** - * @brief Creates a new, autoreleased thread join failed exception. - * - * @param thread The thread which could not be joined - * @param errNo The errno of the error that occurred - * @return A new, autoreleased thread join failed exception - */ -+ (instancetype)exceptionWithThread: (nullable OFThread *)thread - errNo: (int)errNo; - -+ (instancetype)exception OF_UNAVAILABLE; - -/** - * @brief Initializes an already allocated thread join failed exception. - * - * @param thread The thread which could not be joined - * @param errNo The errno of the error that occurred - * @return An initialized thread join failed exception - */ -- (instancetype)initWithThread: (nullable OFThread *)thread - errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - -- (instancetype)init OF_UNAVAILABLE; -@end - -OF_ASSUME_NONNULL_END DELETED src/exceptions/OFThreadJoinFailedException.m Index: src/exceptions/OFThreadJoinFailedException.m ================================================================== --- src/exceptions/OFThreadJoinFailedException.m +++ src/exceptions/OFThreadJoinFailedException.m @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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" - -#include - -#import "OFThreadJoinFailedException.h" -#import "OFString.h" -#import "OFThread.h" - -@implementation OFThreadJoinFailedException -@synthesize thread = _thread, errNo = _errNo; - -+ (instancetype)exceptionWithThread: (OFThread *)thread errNo: (int)errNo -{ - return [[[self alloc] initWithThread: thread errNo: errNo] autorelease]; -} - -+ (instancetype)exception -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (instancetype)initWithThread: (OFThread *)thread errNo: (int)errNo -{ - self = [super init]; - - _thread = [thread retain]; - _errNo = errNo; - - return self; -} - -- (instancetype)init -{ - OF_INVALID_INIT_METHOD -} - -- (void)dealloc -{ - [_thread release]; - - [super dealloc]; -} - -- (OFString *)description -{ - return [OFString stringWithFormat: - @"Joining a thread of type %@ failed: %s", - _thread.class, strerror(_errNo)]; -} -@end DELETED src/exceptions/OFThreadStartFailedException.h Index: src/exceptions/OFThreadStartFailedException.h ================================================================== --- src/exceptions/OFThreadStartFailedException.h +++ src/exceptions/OFThreadStartFailedException.h @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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" - -#ifndef OF_HAVE_THREADS -# error No threads available! -#endif - -OF_ASSUME_NONNULL_BEGIN - -@class OFThread; - -/** - * @class OFThreadStartFailedException \ - * OFThreadStartFailedException.h ObjFW/OFThreadStartFailedException.h - * - * @brief An exception indicating that starting a thread failed. - */ -@interface OFThreadStartFailedException: OFException -{ - OFThread *_Nullable _thread; - int _errNo; - OF_RESERVE_IVARS(OFThreadStartFailedException, 4) -} - -/** - * @brief The thread which could not be started. - */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFThread *thread; - -/** - * @brief The errno of the error that occurred. - */ -@property (readonly, nonatomic) int errNo; - -/** - * @brief Creates a new, autoreleased thread start failed exception. - * - * @param thread The thread which could not be started - * @param errNo The errno of the error that occurred - * @return A new, autoreleased thread start failed exception - */ -+ (instancetype)exceptionWithThread: (nullable OFThread *)thread - errNo: (int)errNo; - -+ (instancetype)exception OF_UNAVAILABLE; - -/** - * @brief Initializes an already allocated thread start failed exception. - * - * @param thread The thread which could not be started - * @param errNo The errno of the error that occurred - * @return An initialized thread start failed exception - */ -- (instancetype)initWithThread: (nullable OFThread *)thread - errNo: (int)errNo OF_DESIGNATED_INITIALIZER; - -- (instancetype)init OF_UNAVAILABLE; -@end - -OF_ASSUME_NONNULL_END DELETED src/exceptions/OFThreadStartFailedException.m Index: src/exceptions/OFThreadStartFailedException.m ================================================================== --- src/exceptions/OFThreadStartFailedException.m +++ src/exceptions/OFThreadStartFailedException.m @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2008-2022 Jonathan Schleifer - * - * 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" - -#include - -#import "OFThreadStartFailedException.h" -#import "OFString.h" -#import "OFThread.h" - -@implementation OFThreadStartFailedException -@synthesize thread = _thread, errNo = _errNo; - -+ (instancetype)exceptionWithThread: (OFThread *)thread errNo: (int)errNo -{ - return [[[self alloc] initWithThread: thread errNo: errNo] autorelease]; -} - -+ (instancetype)exception -{ - OF_UNRECOGNIZED_SELECTOR -} - -- (instancetype)initWithThread: (OFThread *)thread errNo: (int)errNo -{ - self = [super init]; - - _thread = [thread retain]; - _errNo = errNo; - - return self; -} - -- (instancetype)init -{ - OF_INVALID_INIT_METHOD -} - -- (void)dealloc -{ - [_thread release]; - - [super dealloc]; -} - -- (OFString *)description -{ - return [OFString stringWithFormat: - @"Starting a thread of type %@ failed: %s", - _thread.class, strerror(_errNo)]; -} -@end ADDED src/exceptions/OFWaitForConditionFailedException.h Index: src/exceptions/OFWaitForConditionFailedException.h ================================================================== --- src/exceptions/OFWaitForConditionFailedException.h +++ src/exceptions/OFWaitForConditionFailedException.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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" + +#ifndef OF_HAVE_THREADS +# error No threads available! +#endif + +OF_ASSUME_NONNULL_BEGIN + +@class OFCondition; + +/** + * @class OFWaitForConditionFailedException \ + * OFWaitForConditionFailedException.h \ + * ObjFW/OFWaitForConditionFailedException.h + * + * @brief An exception indicating waiting for a condition failed. + */ +@interface OFWaitForConditionFailedException: OFException +{ + OFCondition *_condition; + int _errNo; + OF_RESERVE_IVARS(OFWaitForConditionFailedException, 4) +} + +/** + * @brief The condition for which could not be waited. + */ +@property (readonly, nonatomic) OFCondition *condition; + +/** + * @brief The errno of the error that occurred. + */ +@property (readonly, nonatomic) int errNo; + +/** + * @brief Creates a new, autoreleased condition wait failed exception. + * + * @param condition The condition for which could not be waited + * @param errNo The errno of the error that occurred + * @return A new, autoreleased condition wait failed exception + */ ++ (instancetype)exceptionWithCondition: (OFCondition *)condition + errNo: (int)errNo; + ++ (instancetype)exception OF_UNAVAILABLE; + +/** + * @brief Initializes an already allocated condition wait failed exception. + * + * @param condition The condition for which could not be waited + * @param errNo The errno of the error that occurred + * @return An initialized condition wait failed exception + */ +- (instancetype)initWithCondition: (OFCondition *)condition + errNo: (int)errNo OF_DESIGNATED_INITIALIZER; + +- (instancetype)init OF_UNAVAILABLE; +@end + +OF_ASSUME_NONNULL_END ADDED src/exceptions/OFWaitForConditionFailedException.m Index: src/exceptions/OFWaitForConditionFailedException.m ================================================================== --- src/exceptions/OFWaitForConditionFailedException.m +++ src/exceptions/OFWaitForConditionFailedException.m @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2008-2022 Jonathan Schleifer + * + * 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" + +#include + +#import "OFWaitForConditionFailedException.h" +#import "OFString.h" +#import "OFCondition.h" + +@implementation OFWaitForConditionFailedException +@synthesize condition = _condition, errNo = _errNo; + ++ (instancetype)exceptionWithCondition: (OFCondition *)condition + errNo: (int)errNo +{ + return [[[self alloc] initWithCondition: condition + errNo: errNo] autorelease]; +} + ++ (instancetype)exception +{ + OF_UNRECOGNIZED_SELECTOR +} + +- (instancetype)initWithCondition: (OFCondition *)condition errNo: (int)errNo +{ + self = [super init]; + + _condition = [condition retain]; + _errNo = errNo; + + return self; +} + +- (instancetype)init +{ + OF_INVALID_INIT_METHOD +} + +- (void)dealloc +{ + [_condition release]; + + [super dealloc]; +} + +- (OFString *)description +{ + return [OFString stringWithFormat: + @"Waiting for a condition of type %@ failed: %s", + _condition.class, strerror(_errNo)]; +} +@end