Skip to content
This repository was archived by the owner on May 3, 2022. It is now read-only.
This repository was archived by the owner on May 3, 2022. It is now read-only.

Barrier subscriptions overwrite each other #33

@krakowski

Description

@krakowski

Barriers seem to be implemented using dynamic message receivers, which block until a specific message arrives. Whenever someone creates two of them, the second overwrites the firsts subscription. In addition a semaphore is used, which results in blocking one of the available message handler threads.

public BarrierStatus barrierSignOn(final int p_barrierId, final long p_customData, final boolean p_waitForRelease) {
if (p_barrierId == BarrierID.INVALID_ID) {
return null;
}
Semaphore waitForRelease = new Semaphore(0);
MessageReceiver msg = null;
final BarrierReleaseMessage[] releaseMessage = {null};
if (p_waitForRelease) {
msg = p_message -> {
if (p_message != null) {
if (p_message.getType() == DXRAMMessageTypes.LOOKUP_MESSAGES_TYPE) {
switch (p_message.getSubtype()) {
case LookupMessages.SUBTYPE_BARRIER_RELEASE_MESSAGE: {
releaseMessage[0] = (BarrierReleaseMessage) p_message;
if (releaseMessage[0].getBarrierId() == p_barrierId) {
waitForRelease.release();
}
break;
}
default:
break;
}
}
}
};
// make sure to register the listener BEFORE sending the sign on to not miss the release message
m_network.register(DXRAMMessageTypes.LOOKUP_MESSAGES_TYPE, LookupMessages.SUBTYPE_BARRIER_RELEASE_MESSAGE,
msg);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions