Skip to content

Commit 0928163

Browse files
committed
Add convenience to unregister multiple delayed sigactions at the same time
1 parent 13ee4bd commit 0928163

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

Sources/SignalHandling/DelayedSigaction/SigactionDelayer_Block.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,23 @@ public enum SigactionDelayer_Block {
127127
}
128128
}
129129

130+
/**
131+
Convenience to unregister a set of delayed sigactions in one function call.
132+
133+
All of the delayed sigaction will be attempted to be unregistered. Errors
134+
will be returned. The function is successful if the returned dictionary is
135+
empty. */
136+
public static func unregisterDelayedSigactions(_ delayedSigactions: Set<DelayedSigaction>) -> [DelayedSigaction: Error] {
137+
return signalProcessingQueue.sync{
138+
var ret = [DelayedSigaction: Error]()
139+
for delayedSigaction in delayedSigactions {
140+
do {try Self.unregisterDelayedSigactionOnQueue(delayedSigaction)}
141+
catch {ret[delayedSigaction] = error}
142+
}
143+
return ret
144+
}
145+
}
146+
130147
/* ***************
131148
   MARK: - Private
132149
   *************** */

Sources/SignalHandling/DelayedSigaction/SigactionDelayer_Unsig.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,23 @@ public enum SigactionDelayer_Unsig {
6464
}
6565
}
6666

67+
/**
68+
Convenience to unregister a set of delayed sigactions in one function call.
69+
70+
All of the delayed sigaction will be attempted to be unregistered. Errors
71+
will be returned. The function is successful if the returned dictionary is
72+
empty. */
73+
public static func unregisterDelayedSigactions(_ delayedSigactions: Set<DelayedSigaction>) -> [DelayedSigaction: Error] {
74+
return signalProcessingQueue.sync{
75+
var ret = [DelayedSigaction: Error]()
76+
for delayedSigaction in delayedSigactions {
77+
do {try Self.unregisterDelayedSigactionOnQueue(delayedSigaction)}
78+
catch {ret[delayedSigaction] = error}
79+
}
80+
return ret
81+
}
82+
}
83+
6784
/**
6885
Change the original sigaction of the given signal if it was registered for an
6986
unsigaction. This is useful if you want to change the sigaction handler after

0 commit comments

Comments
 (0)