public void Add (Indexable indexable, Scheduler.Priority priority)
		{
			lock (indexables) {
				indexables.Enqueue (indexable);

				if (priority > highest_prio)
					highest_prio = priority;

				if (self_task == null) {
					self_task = queryable.NewAddTask (this);
					self_task.Priority = highest_prio;
					queryable.ThisScheduler.Add (self_task);
				} else {
					self_task.Priority = highest_prio;
				}
			}
		}
		private void ScheduleOptimize ()
		{
			double optimize_delay;

			// Really we only want to optimize at most once a day, even if we have
			// indexed a ton of dat
			TimeSpan span = DateTime.Now - last_optimize_time;
			if (span.TotalDays > 1.0)
				optimize_delay = 10.0; // minutes;
			else
				optimize_delay = (new TimeSpan (TimeSpan.TicksPerDay) - span).TotalMinutes;

			if (our_optimize_task == null)
				our_optimize_task = NewOptimizeTask ();

			if (OptimizeRightAway || Environment.GetEnvironmentVariable ("BEAGLE_UNDER_BLUDGEON") != null)
				optimize_delay = 1/120.0; // half a second

			// Changing the trigger time of an already-scheduled process
			// does what you would expect.
			our_optimize_task.TriggerTime = DateTime.Now.AddMinutes (optimize_delay);

			// Adding the same task more than once is a harmless no-op.
			ThisScheduler.Add (our_optimize_task);
		}
		private void ScheduleFinalFlush ()
		{
			if (our_final_flush_task == null) {
				our_final_flush_task = new FinalFlushTask (this);

				our_final_flush_task.Tag = "Final Flush for " + IndexName;
				our_final_flush_task.Priority = Scheduler.Priority.Maintenance;
				our_final_flush_task.SubPriority = 100; // do this first when starting maintenance
				our_final_flush_task.Source = this;
			}
			
			ThisScheduler.Add (our_final_flush_task);
		}
			public void Add (string dir_name, string file_name, bool addition)
			{
				lock (queue_lock) {
					event_queue.Enqueue (new Event (dir_name, file_name, addition));

					if (self_task == null) {
						self_task = queryable.NewAddTask (this);
						self_task.Priority = Scheduler.Priority.Immediate;
						queryable.ThisScheduler.Add (self_task);
					}
				}
			}
			public void PostFlushHook ()
			{
				lock (queue_lock) {
					if (event_queue.Count > 0)
						self_task.Reschedule = true;
					else
						self_task = null;
				}
			}
		public void PostFlushHook ()
		{
			lock (indexables) {
				self_task.Description = String.Format ("{0} indexables to process", indexables.Count);

				if (indexables.Count > 0)
					self_task.Reschedule = true;
				else {
					// Instruct the scheduler to not reschedule
					// this task. Otherwise AddIndexableGenerator
					// might reschedule this task once more
					// to figure out there is no more
					// indexables.
					self_task.Reschedule = false;
					self_task = null;
				}
			}
		}