The following simple Promise is vowed and I am not allowed to break it.
my $my_promise = start {
loop {} # or sleep x;
'promise response'
}
say 'status : ', $my_promise.status; # status : Planned
$my_promise.break('promise broke'); # Access denied to keep/break this Promise; already vowed
# in block <unit> at xxx line xxx
Why is that?
Because the Promise is vowed, you cannot change it: only something that actually has the vow, can break the Promise. That is the intent of the
vowfunctionality.What are you trying to achieve by breaking the promise as you showed? Is it to stop the work being done inside of the
startblock? Breaking the Promise would not do that. And thevowmechanism was explicitly added to prevent you from thinking it can somehow stop the work inside astartblock.If you want work inside a
startblock to be interruptible, you will need to add some kind of semaphore that is regularly checked, for instance:Hope this made sense.