Skip to content

Commit 6fe019a

Browse files
committed
Add mechanism to register (noisy) signal handler
This allows programs that are waiting on a signal to proceed to work. Sometimes, there are programs that are waiting for an alarm, or similar prior to performing I/O. This was impossible, because signal handlers were never registered as noisy actors in asio. This allows for an optional named parameter to be passed with that context.
1 parent b154f12 commit 6fe019a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/signals/signal_handler.pony

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,21 @@ use @pony_asio_event_destroy[None](event: AsioEventID)
1010
actor SignalHandler
1111
"""
1212
Listen for a specific signal.
13+
If the wait parameter is true, the program will not terminate until the SignalHandler's dispose method is called.
14+
1315
"""
1416
let _notify: SignalNotify
1517
let _sig: U32
1618
var _event: AsioEventID
1719

18-
new create(notify: SignalNotify iso, sig: U32) =>
20+
new create(notify: SignalNotify iso, sig: U32, wait: Bool = false) =>
1921
"""
2022
Create a signal handler.
2123
"""
2224
_notify = consume notify
2325
_sig = sig
2426
_event =
25-
@pony_asio_event_create(this, 0, AsioEvent.signal(), sig.u64(), false)
27+
@pony_asio_event_create(this, 0, AsioEvent.signal(), sig.u64(), wait)
2628

2729
be raise() =>
2830
"""

0 commit comments

Comments
 (0)