This repository was archived by the owner on May 3, 2022. It is now read-only.
-
Couldn't load subscription status.
- Fork 14
This repository was archived by the owner on May 3, 2022. It is now read-only.
Barrier subscriptions overwrite each other #33
Copy link
Copy link
Open
Labels
Description
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.
dxram/src/main/java/de/hhu/bsinfo/dxram/lookup/overlay/OverlayPeer.java
Lines 813 to 844 in 70d6f34
| 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); | |
| } |