README.rdoc in rufus-scheduler-2.0.18 vs README.rdoc in rufus-scheduler-2.0.19
- old
+ new
@@ -229,9 +229,49 @@
# critical
end
# non-critical
end
+Please note that a mutex can also be used to prevent overlapping executions of the same job:
+
+ scheduler.every '5m', :mutex => 'the_mutex' do
+ puts "order ristretto"
+ # do something that might take more that 5 minutes...
+ puts "ah, that was delicious"
+ end
+
+But beware the cascades...
+
+
+== :mutex => ['mutex_a', 'mutex_b', ...]
+
+Multiple mutexes can be used to ensure exlusivity:
+
+ scheduler.in '20m', :mutex => 'mutex_r' do
+ puts "order ristretto"
+ sleep 2 * 60
+ end
+
+ scheduler.in '20m' :mutex => 'mutex_e' do
+ puts "order espresso"
+ sleep 3 * 60
+ end
+
+ scheduler.in '1h' :mutex => ['mutex_r', 'mutex_e'] do
+ puts "code for fun"
+ end
+
+This allow you order ristretto and espresso at same time, but when you coding it ensure you can't order any thing, and when you ordering anything it ensure you can't code.
+
+Sure you can also use array of Mutex object directly:
+
+ mutex_r = Mutex.new
+ mutex_e = Mutex.new
+ # ...
+ scheduler.in '1h' :mutex => [mutex_r, mutex_e] do
+ puts "code for fun"
+ end
+
== :allow_overlapping => false
By default, every and cron jobs will "overlap":