Skip to content

Commit d4d2b2a

Browse files
committed
Constify a couple members of BoostEnvironment and BoostVM
1 parent a2e06e2 commit d4d2b2a

File tree

6 files changed

+11
-28
lines changed

6 files changed

+11
-28
lines changed

boosthost/emulator/emulator.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,8 @@ int main(int argc, char** argv) {
349349
baseEnv = vm->protect(OptVar::build(vm));
350350

351351
UnstableNode baseValue;
352-
auto& bootLoader = boostEnv.getBootLoader();
353352

354-
if (!bootLoader(vm, baseFunctorPath.string(), baseValue)) {
353+
if (!boostEnv.bootLoader(vm, baseFunctorPath.string(), baseValue)) {
355354
std::cerr << "panic: could not load Base functor at "
356355
<< baseFunctorPath << std::endl;
357356
return false;
@@ -376,9 +375,8 @@ int main(int argc, char** argv) {
376375
initFunctor = vm->protect(OptVar::build(vm));
377376

378377
UnstableNode initValue;
379-
auto& bootLoader = boostEnv.getBootLoader();
380378

381-
if (!bootLoader(vm, initFunctorPath.string(), initValue)) {
379+
if (!boostEnv.bootLoader(vm, initFunctorPath.string(), initValue)) {
382380
std::cerr << "panic: could not load Init functor at "
383381
<< initFunctorPath << std::endl;
384382
return false;

vm/boostenv/main/boostenv-decl.hh

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,6 @@ public:
109109
});
110110
}
111111

112-
// Configuration
113-
114-
public:
115-
const BootLoader& getBootLoader() {
116-
return _bootLoader;
117-
}
118-
119-
void setBootLoader(const BootLoader& loader) {
120-
_bootLoader = loader;
121-
}
122-
123112
// Run and preemption
124113

125114
public:
@@ -199,10 +188,9 @@ private:
199188
boost::mutex _gcMutex;
200189

201190
// Bootstrap
202-
private:
203-
BootLoader _bootLoader;
204191
public:
205-
VMStarter vmStarter;
192+
const BootLoader bootLoader;
193+
const VMStarter vmStarter;
206194

207195
// Unsafe process-wide operations
208196
private:

vm/boostenv/main/boostenv.hh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,8 @@ namespace internal {
113113

114114
BoostEnvironment::BoostEnvironment(const VMStarter& vmStarter) :
115115
_nextVMIdentifier(InitialVMIdentifier), _exitCode(0),
116+
bootLoader(&internal::defaultBootLoader),
116117
vmStarter(vmStarter) {
117-
// Set up a default boot loader
118-
setBootLoader(&internal::defaultBootLoader);
119-
120118
// Ignore SIGPIPE ourselves since Boost does not always do it
121119
#ifdef SIGPIPE
122120
std::signal(SIGPIPE, SIG_IGN);

vm/boostenv/main/boostvm-decl.hh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ public:
134134
}
135135

136136
public:
137-
VM vm;
137+
const VM vm;
138138
BoostEnvironment& env;
139-
VMIdentifier identifier;
139+
const VMIdentifier identifier;
140140

141141
// Random number and UUID generation
142142
public:
@@ -182,7 +182,7 @@ private:
182182

183183
// Running thread management
184184
private:
185-
boost::asio::io_service::work* _work;
185+
boost::asio::io_service::work* const _work;
186186
};
187187

188188
} }

vm/boostenv/main/boostvm.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ BoostVM::BoostVM(BoostEnvironment& environment,
4848
alarmTimer(environment.io_service),
4949
_terminationRequested(false),
5050
_terminationStatus(0),
51-
_terminationReason("normal") {
52-
51+
_terminationReason("normal"),
5352
// Make sure the IO thread will wait for us
54-
_work = new boost::asio::io_service::work(environment.io_service);
53+
_work(new boost::asio::io_service::work(environment.io_service)) {
5554

5655
if (identifier != parent)
5756
addMonitor(parent);

vm/boostenv/main/modos.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public:
8585
std::string urlString;
8686
ozVSGet(vm, url, urlBufSize, urlString);
8787

88-
auto& bootLoader = BoostEnvironment::forVM(vm).getBootLoader();
88+
auto& bootLoader = BoostEnvironment::forVM(vm).bootLoader;
8989
ok = bootLoader && bootLoader(vm, urlString, result);
9090
}
9191

0 commit comments

Comments
 (0)