src/c/scheduler.c
bool iot_schedule_add (iot_scheduler_t * scheduler, iot_schedule_t * schedule)
{
  assert (scheduler && schedule);
  bool ret;
  iot_log_trace (scheduler->logger, "iot_schedule_add()");
  iot_component_lock (&scheduler->component);
  if ((ret = !schedule->scheduled))
  {
    /* Remove from idle queue, add to scheduled queue */
    iot_schedule_requeue (&scheduler->idle_queue, &scheduler->queue, schedule);
    /* If the schedule was placed and the front of the queue & the scheduler is running */
    if (scheduler->queue.front == schedule && (scheduler->component.state == IOT_COMPONENT_RUNNING))
    {
      pthread_cond_signal (&scheduler->component.cond);
    }
    schedule->scheduled = true;
  }
  iot_component_unlock (&scheduler->component);
  return ret;
}
/* Add a schedule to the queue */
Add a schedule to the queue
Add a schedule to the queue
bool iot_schedule_add (iot_scheduler_t * scheduler, iot_schedule_t * schedule)
{
  assert (scheduler && schedule);
  bool ret;
  iot_log_trace (scheduler->logger, "iot_schedule_add()");
  iot_component_lock (&scheduler->component);
  if ((ret = !schedule->scheduled))
  {
    iot_schedule_requeue (&scheduler->idle_queue, &scheduler->queue, schedule);
    if (scheduler->queue.front == schedule && (scheduler->component.state == IOT_COMPONENT_RUNNING))
    {
      pthread_cond_signal (&scheduler->component.cond);
    }
    schedule->scheduled = true;
  }
  iot_component_unlock (&scheduler->component);
  return ret;
}
bool iot_schedule_add ( iot_scheduler_t * scheduler , iot_schedule_t * schedule ) { assert ( scheduler && schedule ) ; bool ret ; iot_log_trace ( scheduler -> logger , " " ) ; iot_component_lock ( & scheduler -> component ) ; if ( ( ret = ! schedule -> scheduled ) ) { iot_schedule_requeue ( & scheduler -> idle_queue , & scheduler -> queue , schedule ) ; if ( scheduler -> queue . front == schedule && ( scheduler -> component . state == IOT_COMPONENT_RUNNING ) ) { pthread_cond_signal ( & scheduler -> component . cond ) ; } schedule -> scheduled = true ; } iot_component_unlock ( & scheduler -> component ) ; return ret ; }
Add a schedule to the queue
Add a schedule to the queue
/* Remove from idle queue, add to scheduled queue */ /* If the schedule was placed and the front of the queue & the scheduler is running */