mirror of
https://github.com/PAMGuard/PAMGuard.git
synced 2024-11-21 22:52:22 +00:00
Synchronizing object packing
Synchronize object packing between the binary store and the network sender since we're having trouble with these two users of data overwriting each others work in progress.
This commit is contained in:
parent
ac004ab9cc
commit
e4c4c95340
@ -41,6 +41,8 @@ public abstract class BinaryDataSource {
|
||||
private boolean saveUpdates = false;
|
||||
|
||||
private BackgroundBinaryWriter backgroundBinaryWriter;
|
||||
|
||||
public static final Object packSynchObject = new Object();
|
||||
|
||||
/**
|
||||
* Create a binary data source. These are used both to store data in binary
|
||||
@ -224,11 +226,13 @@ public abstract class BinaryDataSource {
|
||||
* Then pack the data
|
||||
*/
|
||||
BinaryObjectData data;
|
||||
if (pamDataUnit instanceof BackgroundDataUnit) {
|
||||
data = getBackgroundBinaryWriter().packBackgroundData((BackgroundDataUnit) pamDataUnit);
|
||||
}
|
||||
else {
|
||||
data = getPackedData(pamDataUnit);
|
||||
synchronized (packSynchObject) {
|
||||
if (pamDataUnit instanceof BackgroundDataUnit) {
|
||||
data = getBackgroundBinaryWriter().packBackgroundData((BackgroundDataUnit) pamDataUnit);
|
||||
}
|
||||
else {
|
||||
data = getPackedData(pamDataUnit);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Then put it back to how it was a moment ago.
|
||||
|
@ -75,7 +75,10 @@ public class NetworkObjectPacker {
|
||||
BinaryDataSource binarySource = dataBlock.getBinaryDataSource();
|
||||
int dataType2 = dataBlock.getQuickId();
|
||||
|
||||
BinaryObjectData packedObject = binarySource.getPackedData(dataUnit);
|
||||
BinaryObjectData packedObject = null;
|
||||
synchronized (BinaryDataSource.packSynchObject) {
|
||||
packedObject = binarySource.getPackedData(dataUnit);
|
||||
}
|
||||
byte[] data = packedObject.getData();
|
||||
int duDataLength = data.length + 12;
|
||||
DataUnitBaseData baseData = dataUnit.getBasicData();
|
||||
|
Loading…
Reference in New Issue
Block a user