Skip to content
Snippets Groups Projects
Commit 0bb417fd authored by Florian Schmaus's avatar Florian Schmaus
Browse files

[TellActorFromAnywhereTest] Heap allocate Actor and BPS

Allocate the Actor and the BPS on the heap as otherwise Fibers may
access already destructed Actor data.
parent 04c07281
No related branches found
No related tags found
No related merge requests found
......@@ -18,14 +18,16 @@ class SignallingActor : public Actor<unsigned int> {
};
void emperTest() {
BinaryPrivateSemaphore bps;
SignallingActor signallingActor(bps);
signallingActor.start();
// Heap allocate the Actor and the BPS until we have a way to
// cleanly terminate the Actor.
auto* bps = new BinaryPrivateSemaphore();
auto* signallingActor = new SignallingActor(*bps);
signallingActor->start();
// TODO: Use std::jthread once EMPER uses C++20.
std::thread signallingThread([&] { signallingActor.tellFromAnywhere(1); });
std::thread signallingThread([&] { signallingActor->tellFromAnywhere(1); });
bps.wait();
bps->wait();
// TODO: Remove this once we use std::jthread when EMPER uses C++20.
signallingThread.join();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment