Skip to content

Commit 181ebf7

Browse files
authored
Merge pull request #308 from layus/fix-race-condition
Synchronize preemptionTimer creation
2 parents 0919f33 + 9914251 commit 181ebf7

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

vm/boostenv/main/boostvm.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ BoostVM::BoostVM(BoostEnvironment& environment,
5050
uuidGenerator(),
5151
portClosed(false),
5252
_asyncIONodeCount(0),
53-
preemptionTimer(nullptr),
53+
preemptionTimer(new boost::asio::deadline_timer(environment.io_service)),
5454
alarmTimer(environment.io_service),
5555
_terminationRequested(false),
5656
_terminationStatus(0),
@@ -103,10 +103,6 @@ void BoostVM::run() {
103103
constexpr auto recInvokeAgainNow = VirtualMachine::recInvokeAgainNow;
104104
constexpr auto recInvokeAgainLater = VirtualMachine::recInvokeAgainLater;
105105

106-
env.io_service.post([&] {
107-
preemptionTimer = new boost::asio::deadline_timer(env.io_service);
108-
});
109-
110106
// The main loop that handles all interactions with the VM
111107
while (true) {
112108
// Make sure the VM knows the reference time before starting

0 commit comments

Comments
 (0)