summaryrefslogtreecommitdiff
path: root/TAO/tests/Bug_1482_Regression/Hello.cpp
blob: 40d7a6c63e73674315a13151c56b865f8ff87453 (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
//
// $Id$
//
#include "Hello.h"
#include "ace/ACE.h"


ACE_RCSID (Bug_1482_Regression,
           Hello,
           "$Id$")


Hello::Hello (CORBA::ORB_ptr orb)
  : orb_ (CORBA::ORB::_duplicate (orb))
    , mutex_ ()
    , latest_prime_ (0)
{
}

CORBA::ULong
Hello::next_prime (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC ((CORBA::SystemException))
{
  ACE_GUARD_RETURN (TAO_SYNCH_MUTEX,
                    ace_mon,
                    this->mutex_,
                    this->latest_prime_);

  if (this->latest_prime_ > 10000)
    ACE_OS::abort ();

  for (CORBA::Long ind = 0;
       ind != 400;
       ++ind)
    {
      CORBA::Short bc = 0;

      while (bc == 0)
        {
          if (ACE::is_prime (++this->latest_prime_,
                             2,
                             this->latest_prime_/2) == 0)
            bc = 1;
        }
    }

  return this->latest_prime_;
}