summaryrefslogtreecommitdiff
path: root/DAnCE/dance/LocalityManager/Scheduler/Deployment_Completion.h
blob: 0381bf53e5b6d175154056caa2b399f62d07cc37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
 * @file Deployment_Completion.h
 * @author William R. Otte <wotte@dre.vanderbilt.edu>
 *
 * $Id$
 *
 * Future observer that signals when the scheduler has completed.
 */

#ifndef DEPLOYMENT_COMPLETION_H
#define DEPLOYMENT_COMPLETION_H

#include /**/ "ace/pre.h"

#include "ace/Condition_T.h"
#include "ace/Future.h"
#include "Completion/Completion_Counter_Base.h"
#include "dance/LocalityManager/Scheduler/Deployment_Event.h"
#include "dance/LocalityManager/Scheduler/Deployment_Scheduler.h"

namespace DAnCE
{
  /**
   * @class Event_Handler
   */
  class Deployment_Scheduler_Export Deployment_Completion
    : public virtual ACE_Future_Observer< Event_Result >,
      public virtual Completion_Counter_Base< TAO_SYNCH_MUTEX >
  {
  public:
    Deployment_Completion (Deployment_Scheduler &sched);

    virtual ~Deployment_Completion (void);

    virtual void update (const Event_Future &future);

    void accept (Event_Future &future);

    /// Waits for completion of all events, with a timeout
    bool wait_on_completion (ACE_Time_Value *tv);

    void completed_events (Event_List &event_list);

  protected:
    virtual void on_all_completed ();

    virtual void on_all_completed_with_failure ();

    bool single_threaded_wait_on_completion (ACE_Time_Value *tv);

  private:
    Deployment_Scheduler &sched_;

    TAO_SYNCH_MUTEX mutex_;
    ACE_Condition< TAO_SYNCH_MUTEX > condition_;

    Event_List completed_events_;
  };

}

#include /**/ "ace/post.h"

#endif