summaryrefslogtreecommitdiff
path: root/TAO/tao/LF_Strategy_Complete.cpp
blob: 7bda47e9b16af9771c47a51f27699e2fa785096c (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
// -*- C++ -*-
// $Id$

#include "tao/LF_Strategy_Complete.h"
#include "tao/Leader_Follower.h"

#if !defined (__ACE_INLINE__)
# include "tao/LF_Strategy_Complete.inl"
#endif /* __ACE_INLINE__ */

ACE_RCSID(tao, LF_Strategy_Complete, "$Id$")

TAO_LF_Strategy_Complete::~TAO_LF_Strategy_Complete (void)
{
}

void
TAO_LF_Strategy_Complete::set_upcall_thread (TAO_Leader_Follower &lf)
{
  lf.set_upcall_thread ();
}

int
TAO_LF_Strategy_Complete::set_event_loop_thread (ACE_Time_Value *tv,
                                                 TAO_Leader_Follower &lf)
{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, lf.lock (), -1);

  return lf.set_event_loop_thread (tv);
}

void
TAO_LF_Strategy_Complete::reset_event_loop_thread (int call_reset,
                                                   TAO_Leader_Follower &lf)
{
  ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, lf.lock ());

  if (call_reset)
    lf.reset_event_loop_thread ();

  int result = lf.elect_new_leader ();

  if (result == -1)
    ACE_ERROR ((LM_ERROR,
                ACE_TEXT ("TAO (%P|%t) Failed to wake up ")
                ACE_TEXT ("a follower thread\n")));
}