Thanks kcott and everyone for the time and energy involved with this.
I feel obligated that I should go further to ask the module author for help if he can explain it further on the example. The mentioned 2 lines
my $end = $delay->begin;
...
$end->();
are related to IOLoop. From the documentation, each $delay->begin would increment the event counter and the returned code reference can be used as a callback. The callback needs to be executed when the event has completed to decrement the event counter again. However, I just cannot understand the recursion in this case failed to continue calling itself without the for loop.
The following is the question that I raised in the issue report:
https://github.com/kraih/mojo/issues/1147#issuecomment-341304178