/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2013 University of California, Los Angeles
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation;
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
 *         Alexander Afanasyev <alexander.afanasyev@ucla.edu>
 */

#ifndef SCHEDULER_H
#define SCHEDULER_H

#include <event2/event.h>
#include <event2/thread.h>
#include <event2/event-config.h>
#include <event2/util.h>

#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>

#include <boost/exception/all.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/thread.hpp>
#include <math.h>
#include <map>
#include <sys/time.h>

#include "task.h"
#include "interval-generator.h"
#include "executor.h"

class Scheduler;
typedef boost::shared_ptr<Scheduler> SchedulerPtr;

/**
 * @brief Scheduler class
 */
class Scheduler
{
public:
  Scheduler();
  virtual ~Scheduler();

  // start event scheduling
  virtual void
  start();

  // stop event scheduling
  virtual void
  shutdown();

  // helper method to schedule one-time task
  static TaskPtr
  scheduleOneTimeTask (SchedulerPtr scheduler, double delay, const Task::Callback &callback, const Task::Tag &tag);

  // helper method to schedule periodic task
  static TaskPtr
  schedulePeriodicTask (SchedulerPtr scheduler, IntervalGeneratorPtr delayGenerator,
                        const Task::Callback &callback, const Task::Tag &tag);

  // if task with the same tag exists, the task is not added and return false
  virtual bool
  addTask(TaskPtr task, bool reset = true);

  // delete task by task->tag, regardless of whether it's invoked or not
  virtual void
  deleteTask(TaskPtr task);

  // delete task by tag, regardless of whether it's invoked or not
  // if no task is found, no effect
  virtual void
  deleteTask(const Task::Tag &tag);

  // delete tasks by matcher, regardless of whether it's invoked or not
  // this is flexiable in that you can use any form of criteria in finding tasks to delete
  // but keep in mind this is a linear scan

  // if no task is found, no effect
  virtual void
  deleteTask(const Task::TaskMatcher &matcher);

  // task must already have been added to the scheduler, otherwise this method has no effect
  // this is usually used by PeriodicTask
  virtual void
  rescheduleTask(const Task::Tag &tag);

  // if the task is not pending, it will be added to the schedule queue
  // if the task is pending, the delay is changed to the passed in delay
  // e.g. if at second 0 task A with delay 5 is originally going to run at second 5 and
  // rescheduleTask(A) is called at second 4, A will be reschedule to run
  // at second 9
  virtual void
  rescheduleTask(TaskPtr task);

  virtual void
  rescheduleTaskAt (const Task::Tag &tag, double time);

  virtual void
  rescheduleTaskAt (TaskPtr task, double time);

  void
  execute(Executor::Job);

  void
  eventLoop();

  event_base *
  base() { return m_base; }

  // used in test
  int
  size();

protected:
  bool
  addToMap(TaskPtr task);

protected:
  typedef std::map<Task::Tag, TaskPtr> TaskMap;
  typedef std::map<Task::Tag, TaskPtr>::iterator TaskMapIt;
  typedef boost::recursive_mutex Mutex;
  typedef boost::unique_lock<Mutex> ScopedLock;

  TaskMap m_taskMap;
  Mutex m_mutex;
  volatile bool m_running;
  event_base *m_base;
  event *m_ev;
  boost::thread m_thread;
  Executor m_executor;
};

struct SchedulerException : virtual boost::exception, virtual std::exception { };

#endif // SCHEDULER_H
