Differences From Artifact [24791db544]:
- File src/OFCondition.m — part of check-in [c7f0229795] at 2020-01-02 01:51:34 on branch trunk — Update copyright (user: js, size: 3275) [annotate] [blame] [check-ins using] [more...]
To Artifact [53f832df7b]:
- File
src/OFCondition.m
— part of check-in
[5b37fbeb82]
at
2020-12-20 21:26:08
on branch trunk
— Return error instead of using errno for threading
errno is problematic for Amiga libraries and is also not thread-safe on
some systems, even though it should. (user: js, size: 3428) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
34 35 36 37 38 39 40 | return [[[self alloc] init] autorelease]; } - (instancetype)init { self = [super init]; | | | > > | | > > | | > > > | | > | | | > | | | < | | > | | | > | | | < | 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 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 | return [[[self alloc] init] autorelease]; } - (instancetype)init { self = [super init]; if (of_condition_new(&_condition) != 0) { Class c = self.class; [self release]; @throw [OFInitializationFailedException exceptionWithClass: c]; } _conditionInitialized = true; return self; } - (void)dealloc { if (_conditionInitialized) { int error = of_condition_free(&_condition); if (error != 0) { OF_ENSURE(error == EBUSY); @throw [OFConditionStillWaitingException exceptionWithCondition: self]; } } [super dealloc]; } - (void)wait { int error = of_condition_wait(&_condition, &_mutex); if (error != 0) @throw [OFConditionWaitFailedException exceptionWithCondition: self errNo: error]; } #ifdef OF_AMIGAOS - (void)waitForConditionOrExecSignal: (ULONG *)signalMask { int error = of_condition_wait_or_signal(&_condition, &_mutex, signalMask); if (error != 0) @throw [OFConditionWaitFailedException exceptionWithCondition: self errNo: error]; } #endif - (bool)waitForTimeInterval: (of_time_interval_t)timeInterval { int error = of_condition_timed_wait(&_condition, &_mutex, timeInterval); if (error == ETIMEDOUT) return false; if (error != 0) @throw [OFConditionWaitFailedException exceptionWithCondition: self errNo: error]; return true; } #ifdef OF_AMIGAOS - (bool)waitForTimeInterval: (of_time_interval_t)timeInterval orExecSignal: (ULONG *)signalMask { int error = of_condition_timed_wait_or_signal(&_condition, &_mutex, timeInterval, signalMask); if (error == ETIMEDOUT) return false; if (error != 0) @throw [OFConditionWaitFailedException exceptionWithCondition: self errNo: error]; return true; } #endif - (bool)waitUntilDate: (OFDate *)date { |
︙ | ︙ | |||
125 126 127 128 129 130 131 | return [self waitForTimeInterval: date.timeIntervalSinceNow orExecSignal: signalMask]; } #endif - (void)signal { | | > > | | > > | | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | return [self waitForTimeInterval: date.timeIntervalSinceNow orExecSignal: signalMask]; } #endif - (void)signal { int error = of_condition_signal(&_condition); if (error != 0) @throw [OFConditionSignalFailedException exceptionWithCondition: self errNo: error]; } - (void)broadcast { int error = of_condition_broadcast(&_condition); if (error != 0) @throw [OFConditionBroadcastFailedException exceptionWithCondition: self errNo: error]; } @end |