blob: ec7e9a3b5e9e63d832e94d1eb7e883d42257c7f4 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#include "Process_Priority.h"
#include "dance/DAnCE_PropertiesC.h"
#include "dance/Deployment/Deployment_StartErrorC.h"
#include "dance/Logger/Log_Macros.h"
#include <sstream>
#include "ace/Auto_Ptr.h"
namespace DAnCE
{
Process_Priority::Process_Priority (void)
{
}
// Implementation skeleton destructor
Process_Priority::~Process_Priority (void)
{
}
char * Process_Priority::type (void)
{
return CORBA::string_dup (DAnCE::DANCE_LM_PROCESSPRIORITY);
}
void Process_Priority::configure (const ::Deployment::Property & prop)
{
CORBA::Long prio;
if (!(prop.value >>= prio))
{
DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
(LM_ERROR, DLINFO
ACE_TEXT ("Process_Priority::configure - ")
ACE_TEXT ("Unable to extract priority value from config property\n")));
throw ::Deployment::PlanError (prop.name.in (),
"Unable to extract priority value from config property.");
}
ACE_hthread_t handle;
ACE_OS::thr_self (handle);
int retval = ACE_OS::thr_setprio (handle,
static_cast<int> (prio),
-1);
if (retval != 0)
{
std::stringstream str;
const char * safe_error (ACE_OS::strerror (ACE_OS::last_error ()));
str << "Unable to set process priority to <" << prio << ">: "
<< safe_error;
std::string message = str.str ();
DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR,
(LM_ERROR, DLINFO
ACE_TEXT ("Process_Priority::configure - %C\n"),
message.c_str ()));
throw ::Deployment::StartError (prop.name.in (),
message.c_str ());
}
}
}
extern "C"
{
DAnCE::LocalityConfiguration_ptr create_Process_Priority (void)
{
DAnCE::LocalityConfiguration_ptr retval (0);
ACE_NEW_RETURN (retval,
DAnCE::Process_Priority (),
0);
return retval;
}
}
|