<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,8 +1,11 @@
 
 = rufus-scheduler CHANGELOG.txt
 
+
 == rufus-scheduler - 2.0.2    not yet released
 
+- unified JobQueue and CronJobQueue, and handed @last_second management to the
+  latter
 - #trigger_block method for easier override
 - passing :job =&gt; job among Schedulable trigger parameters
 </diff>
      <filename>CHANGELOG.txt</filename>
    </modified>
    <modified>
      <diff>@@ -52,7 +52,9 @@ module Scheduler
 
     # Triggers all the jobs that are scheduled for 'now'.
     #
-    def trigger_matching_jobs (now)
+    def trigger_matching_jobs
+
+      now = Time.now
 
       while job = job_to_trigger(now)
         job.trigger
@@ -124,42 +126,28 @@ module Scheduler
   #
   # Tracking cron jobs.
   #
-  # (mostly synchronizing access to the map of cron jobs)
-  #
-  class CronJobQueue
+  class CronJobQueue &lt; JobQueue
 
-    def initialize
+    def trigger_matching_jobs
 
-      @mutex = Mutex.new
-      @jobs = {}
-    end
+      now = Time.now
 
-    def unschedule (job_id)
+      return if now.sec == @last_cron_second
+      @last_cron_second = now.sec
+        #
+        # ensuring the crons are checked within 1 second (not 1.2 second)
 
-      @mutex.synchronize { @jobs.delete(job_id) }
-    end
-
-    def trigger_matching_jobs (now)
-
-      js = @mutex.synchronize { @jobs.values }
-        # maybe this sync is a bit paranoid
+      jobs = @mutex.synchronize { @jobs.dup }
 
-      js.each { |job| job.trigger_if_matches(now) }
+      jobs.each { |job| job.trigger_if_matches(now) }
     end
 
     def &lt;&lt; (job)
 
-      @mutex.synchronize { @jobs[job.job_id] = job }
-    end
-
-    def size
-
-      @jobs.size
-    end
-
-    def to_h
-
-      @jobs.dup
+      @mutex.synchronize do
+        delete(job.job_id)
+        @jobs &lt;&lt; job
+      end
     end
   end
 </diff>
      <filename>lib/rufus/sc/jobqueues.rb</filename>
    </modified>
    <modified>
      <diff>@@ -277,29 +277,8 @@ module Rufus::Scheduler
     #
     def step
 
-      cron_step
-      at_step
-    end
-
-    # calls every second
-    #
-    def cron_step
-
-      now = Time.now
-      return if now.sec == @last_cron_second
-      @last_cron_second = now.sec
-        #
-        # ensuring the crons are checked within 1 second (not 1.2 second)
-
-      @cron_jobs.trigger_matching_jobs(now)
-    end
-
-    def at_step
-
-      #while job = @jobs.job_to_trigger
-      #  job.trigger
-      #end
-      @jobs.trigger_matching_jobs(Time.now)
+      @cron_jobs.trigger_matching_jobs
+      @jobs.trigger_matching_jobs
     end
 
     def add_job (job)</diff>
      <filename>lib/rufus/sc/scheduler.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>96596c051e8fa0af41d5bc474f4e6c55f40c11e6</id>
    </parent>
  </parents>
  <author>
    <name>John Mettraux</name>
    <email>jmettraux@gmail.com</email>
  </author>
  <url>http://github.com/jmettraux/rufus-scheduler/commit/8b22d55bd21bc3782281332158ebea60ca2f943e</url>
  <id>8b22d55bd21bc3782281332158ebea60ca2f943e</id>
  <committed-date>2009-06-23T02:01:41-07:00</committed-date>
  <authored-date>2009-06-23T02:01:41-07:00</authored-date>
  <message>unified JobQueue and CronJobQueue

and handed @last_second management to the latter</message>
  <tree>7160ff0d599c0a7e45ef6b5d6679213c19f1fc36</tree>
  <committer>
    <name>John Mettraux</name>
    <email>jmettraux@gmail.com</email>
  </committer>
</commit>
