pulled changes
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <cstdio>
|
||||
#include "pvData.h"
|
||||
#include "factory.h"
|
||||
#include "bitSet.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "bitSet.h"
|
||||
#include "lock.h"
|
||||
#include "showConstructDestruct.h"
|
||||
#include "serializeHelper.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -374,55 +375,55 @@ namespace epics { namespace pvData {
|
||||
*buffer += '}';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
void serialize(ByteBuffer buffer, SerializableControl flusher) {
|
||||
|
||||
final int n = wordsInUse;
|
||||
if (n == 0) {
|
||||
SerializeHelper.writeSize(0, buffer, flusher);
|
||||
return;
|
||||
void BitSet::serialize(ByteBuffer* buffer, SerializableControl* flusher) {
|
||||
|
||||
uint32 n = wordsInUse;
|
||||
if (n == 0) {
|
||||
SerializeHelper::writeSize(0, buffer, flusher);
|
||||
return;
|
||||
}
|
||||
uint32 len = 8 * (n-1);
|
||||
for (uint64 x = words[n - 1]; x != 0; x >>= 8)
|
||||
len++;
|
||||
|
||||
SerializeHelper::writeSize(len, buffer, flusher);
|
||||
flusher->ensureBuffer(len);
|
||||
|
||||
for (uint32 i = 0; i < n - 1; i++)
|
||||
buffer->putLong(words[i]);
|
||||
|
||||
for (uint64 x = words[n - 1]; x != 0; x >>= 8)
|
||||
buffer->putByte((int8) (x & 0xff));
|
||||
}
|
||||
|
||||
void BitSet::deserialize(ByteBuffer* buffer, DeserializableControl* control) {
|
||||
|
||||
uint32 bytes = SerializeHelper::readSize(buffer, control); // in bytes
|
||||
|
||||
wordsInUse = (bytes + 7) / 8;
|
||||
if (wordsInUse > wordsLength)
|
||||
{
|
||||
if (words) delete[] words;
|
||||
words = new uint64[wordsInUse];
|
||||
wordsLength = wordsInUse;
|
||||
}
|
||||
|
||||
if (wordsInUse == 0)
|
||||
return;
|
||||
|
||||
control->ensureData(bytes);
|
||||
|
||||
uint32 i = 0;
|
||||
uint32 longs = bytes / 8;
|
||||
while (i < longs)
|
||||
words[i++] = buffer->getLong();
|
||||
|
||||
for (uint32 j = i; j < wordsInUse; j++)
|
||||
words[j] = 0;
|
||||
|
||||
for (uint32 remaining = (bytes - longs * 8), j = 0; j < remaining; j++)
|
||||
words[i] |= (buffer->getByte() & 0xffL) << (8 * j);
|
||||
|
||||
}
|
||||
int len = 8 * (n-1);
|
||||
for (long x = words[n - 1]; x != 0; x >>>= 8)
|
||||
len++;
|
||||
|
||||
SerializeHelper.writeSize(len, buffer, flusher);
|
||||
flusher.ensureBuffer(len);
|
||||
|
||||
for (int i = 0; i < n - 1; i++)
|
||||
buffer.putLong(words[i]);
|
||||
|
||||
for (long x = words[n - 1]; x != 0; x >>>= 8)
|
||||
buffer.put((byte) (x & 0xff));
|
||||
}
|
||||
|
||||
public void deserialize(ByteBuffer buffer, DeserializableControl control) {
|
||||
|
||||
final int bytes = SerializeHelper.readSize(buffer, control); // in bytes
|
||||
|
||||
wordsInUse = (bytes + 7) / 8;
|
||||
if (wordsInUse > words.length)
|
||||
words = new long[wordsInUse];
|
||||
|
||||
if (wordsInUse == 0)
|
||||
return;
|
||||
|
||||
control.ensureData(bytes);
|
||||
|
||||
int i = 0;
|
||||
final int longs = bytes / 8;
|
||||
while (i < longs)
|
||||
words[i++] = buffer.getLong();
|
||||
|
||||
for (int j = i; j < wordsInUse; j++)
|
||||
words[j] = 0;
|
||||
|
||||
for (int remaining = (bytes - longs * 8), j = 0; j < remaining; j++)
|
||||
words[i] |= (buffer.get() & 0xffL) << (8 * j);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}};
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
#include <stdexcept>
|
||||
#include <pvType.h>
|
||||
#include "factory.h"
|
||||
//#include "byteBuffer.h"
|
||||
//#include "serialize.h"
|
||||
#include "serialize.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ namespace epics { namespace pvData {
|
||||
*
|
||||
* Based on Java implementation.
|
||||
*/
|
||||
class BitSet /*: public Serializable*/ {
|
||||
class BitSet : public Serializable {
|
||||
public:
|
||||
|
||||
/**
|
||||
@@ -216,6 +216,11 @@ namespace epics { namespace pvData {
|
||||
|
||||
void toString(StringBuilder buffer, int indentLevel = 0) const;
|
||||
|
||||
virtual void serialize(ByteBuffer *buffer,
|
||||
SerializableControl *flusher);
|
||||
virtual void deserialize(ByteBuffer *buffer,
|
||||
DeserializableControl *flusher);
|
||||
|
||||
private:
|
||||
|
||||
/*
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
*/
|
||||
#ifndef SERIALIZE_H
|
||||
#define SERIALIZE_H
|
||||
#include "bitSet.h"
|
||||
#include "byteBuffer.h"
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
@@ -15,6 +14,7 @@ namespace epics { namespace pvData {
|
||||
class Serializable;
|
||||
class BitSetSerializable;
|
||||
class SerializableArray;
|
||||
class BitSet;
|
||||
|
||||
class SerializableControl {
|
||||
public:
|
||||
|
||||
@@ -69,39 +69,39 @@ extern ShowConstructDestruct* getShowConstructDestruct();
|
||||
#define PVDATA_REFCOUNT_MONITOR_DEFINE(NAME) \
|
||||
static volatile int64 NAME ## _totalConstruct = 0; \
|
||||
static volatile int64 NAME ## _totalDestruct = 0; \
|
||||
static Mutex globalMutex; \
|
||||
static Mutex NAME ## _globalMutex; \
|
||||
\
|
||||
static bool notInited = true; \
|
||||
static bool NAME ## _notInited = true; \
|
||||
static int64 NAME ## _processTotalConstruct() \
|
||||
{ \
|
||||
Lock xx(&globalMutex); \
|
||||
Lock xx(&NAME ## _globalMutex); \
|
||||
return NAME ## _totalConstruct; \
|
||||
} \
|
||||
\
|
||||
static int64 NAME ## _processTotalDestruct() \
|
||||
{ \
|
||||
Lock xx(&globalMutex); \
|
||||
Lock xx(&NAME ## _globalMutex); \
|
||||
return NAME ## _totalDestruct; \
|
||||
} \
|
||||
\
|
||||
static void NAME ## _init() \
|
||||
{ \
|
||||
Lock xx(&globalMutex); \
|
||||
if(notInited) { \
|
||||
notInited = false; \
|
||||
Lock xx(&NAME ## _globalMutex); \
|
||||
if(NAME ## _notInited) { \
|
||||
NAME ## _notInited = false; \
|
||||
ShowConstructDestruct::registerCallback( \
|
||||
String("#NAME"), \
|
||||
NAME ## _processTotalConstruct,NAME ## _processTotalDestruct,0); \
|
||||
String(#NAME), \
|
||||
NAME ## _processTotalConstruct,NAME ## _processTotalDestruct,0,0); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define PVDATA_REFCOUNT_MONITOR_DESTRUCT(NAME) \
|
||||
Lock xx(&globalMutex); \
|
||||
Lock xx(&NAME ## _globalMutex); \
|
||||
NAME ## _totalDestruct++;
|
||||
|
||||
#define PVDATA_REFCOUNT_MONITOR_CONSTRUCT(NAME) \
|
||||
NAME ## _init(); \
|
||||
Lock xx(&globalMutex); \
|
||||
Lock xx(&NAME ## _globalMutex); \
|
||||
NAME ## _totalConstruct++;
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#define BITSETUTIL_H
|
||||
#include "noDefaultMethods.h"
|
||||
#include "pvData.h"
|
||||
#include "bitSet.h"
|
||||
|
||||
namespace epics { namespace pvData {
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
|
||||
Time test
|
||||
diff 23.288030 milliSeconds
|
||||
time per iteration 23.288030 microseconds
|
||||
time per addTail/removeHead 0.011644 microseconds
|
||||
diff 23.955010 milliSeconds
|
||||
time per iteration 23.955010 microseconds
|
||||
time per addTail/removeHead 0.011978 microseconds
|
||||
|
||||
Time test locked
|
||||
diff 175.968013 milliSeconds
|
||||
time per iteration 175.968013 microseconds
|
||||
time per addTail/removeHead 0.087984 microseconds
|
||||
diff 176.706476 milliSeconds
|
||||
time per iteration 176.706476 microseconds
|
||||
time per addTail/removeHead 0.088353 microseconds
|
||||
|
||||
Time std::list test
|
||||
diff 631.892603 milliSeconds
|
||||
time per iteration 631.892603 microseconds
|
||||
time per addTail/removeHead 0.315946 microseconds
|
||||
diff 631.501215 milliSeconds
|
||||
time per iteration 631.501215 microseconds
|
||||
time per addTail/removeHead 0.315751 microseconds
|
||||
|
||||
Time std::list test locked
|
||||
diff 791.255075 milliSeconds
|
||||
time per iteration 791.255075 microseconds
|
||||
time per addTail/removeHead 0.395628 microseconds
|
||||
diff 787.995967 milliSeconds
|
||||
time per iteration 787.995967 microseconds
|
||||
time per addTail/removeHead 0.393998 microseconds
|
||||
|
||||
@@ -1 +1 @@
|
||||
time per call 40.057018 microseconds
|
||||
time per call 40.790343 microseconds
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
current 1295462802 840097682 milliSec 1295462802840
|
||||
2011.01.19 13:46:42 840097682 nanoSeconds isDst false
|
||||
current 1295465466 621311375 milliSec 1295465466621
|
||||
2011.01.19 14:31:06 621311375 nanoSeconds isDst false
|
||||
fromTime_t
|
||||
current 1295462802 0 milliSec 1295462802000
|
||||
2011.01.19 13:46:42 0 nanoSeconds isDst false
|
||||
current 1295465466 0 milliSec 1295465466000
|
||||
2011.01.19 14:31:06 0 nanoSeconds isDst false
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
one requested 0.400000 diff 0.400263 seconds
|
||||
two requested 0.200000 diff 0.200168 seconds
|
||||
one requested 0.200000 diff 0.200136 seconds
|
||||
two requested 0.400000 diff 0.400176 seconds
|
||||
one requested 0.000000 diff 0.000011 seconds
|
||||
two requested 0.000000 diff 0.000018 seconds
|
||||
one requested 0.400000 diff 0.400195 seconds
|
||||
two requested 0.200000 diff 0.200170 seconds
|
||||
one requested 0.200000 diff 0.200124 seconds
|
||||
two requested 0.400000 diff 0.400223 seconds
|
||||
one requested 0.000000 diff 0.000039 seconds
|
||||
two requested 0.000000 diff 0.000060 seconds
|
||||
|
||||
Reference in New Issue
Block a user