*
*/
-#include "config.h"
+#include "squid.h"
#include "base/TextException.h"
#include "Debug.h"
#include "globals.h"
return id;
}
-
/* QueueReader */
InstanceIdDefinitions(Ipc::QueueReader, "ipcQR");
Ipc::QueueReaders::QueueReaders(const int aCapacity): theCapacity(aCapacity)
{
Must(theCapacity > 0);
- new (theReaders) QueueReader[theCapacity];
+ theReaders=new QueueReader[theCapacity];
+}
+
+Ipc::QueueReaders::~QueueReaders()
+{
+ delete[] theReaders;
}
size_t
return sizeof(QueueReaders) + sizeof(QueueReader) * capacity;
}
-
// OneToOneUniQueue
Ipc::OneToOneUniQueue::OneToOneUniQueue(const unsigned int aMaxItemSize, const int aCapacity):
return sizeof(OneToOneUniQueue) + maxItemSize * size;
}
-
/* OneToOneUniQueues */
Ipc::OneToOneUniQueues::OneToOneUniQueues(const int aCapacity, const unsigned int maxItemSize, const int queueCapacity): theCapacity(aCapacity)
return *reinterpret_cast<const OneToOneUniQueue *>(queue);
}
-
// FewToFewBiQueue
Ipc::FewToFewBiQueue::Owner *
debugs(54, 7, HERE << "queue " << id << " reader: " << localReader.id);
}
+int
+Ipc::FewToFewBiQueue::MaxItemsCount(const int groupASize, const int groupBSize, const int capacity)
+{
+ return capacity * groupASize * groupBSize * 2;
+}
+
bool
Ipc::FewToFewBiQueue::validProcessId(const Group group, const int processId) const
{
return (*queues)[oneToOneQueueIndex(fromGroup, fromProcessId, toGroup, toProcessId)];
}
+/// incoming queue from a given remote process
+const Ipc::OneToOneUniQueue &
+Ipc::FewToFewBiQueue::inQueue(const int remoteProcessId) const
+{
+ return oneToOneQueue(remoteGroup(), remoteProcessId,
+ theLocalGroup, theLocalProcessId);
+}
+
+/// outgoing queue to a given remote process
+const Ipc::OneToOneUniQueue &
+Ipc::FewToFewBiQueue::outQueue(const int remoteProcessId) const
+{
+ return oneToOneQueue(theLocalGroup, theLocalProcessId,
+ remoteGroup(), remoteProcessId);
+}
+
int
Ipc::FewToFewBiQueue::readerIndex(const Group group, const int processId) const
{
// theLastPopProcessId = remoteProcessId;
}
-bool
-Ipc::FewToFewBiQueue::popReady() const
-{
- // mimic FewToFewBiQueue::pop() but quit just before popping
- int popProcessId = theLastPopProcessId; // preserve for future pop()
- for (int i = 0; i < remoteGroupSize(); ++i) {
- if (++popProcessId >= remoteGroupIdOffset() + remoteGroupSize())
- popProcessId = remoteGroupIdOffset();
- const OneToOneUniQueue &queue = oneToOneQueue(remoteGroup(), popProcessId, theLocalGroup, theLocalProcessId);
- if (!queue.empty())
- return true;
- }
- return false; // most likely, no process had anything to pop
-}
-
Ipc::QueueReader::Balance &
Ipc::FewToFewBiQueue::localBalance()
{
return r.balance;
}
+const Ipc::QueueReader::Balance &
+Ipc::FewToFewBiQueue::balance(const int remoteProcessId) const
+{
+ const QueueReader &r = reader(remoteGroup(), remoteProcessId);
+ return r.balance;
+}
+
Ipc::QueueReader::Rate &
Ipc::FewToFewBiQueue::localRateLimit()
{
return r.rateLimit;
}
+const Ipc::QueueReader::Rate &
+Ipc::FewToFewBiQueue::rateLimit(const int remoteProcessId) const
+{
+ const QueueReader &r = reader(remoteGroup(), remoteProcessId);
+ return r.rateLimit;
+}
+
Ipc::FewToFewBiQueue::Metadata::Metadata(const int aGroupASize, const int aGroupAIdOffset, const int aGroupBSize, const int aGroupBIdOffset):
theGroupASize(aGroupASize), theGroupAIdOffset(aGroupAIdOffset),
theGroupBSize(aGroupBSize), theGroupBIdOffset(aGroupBIdOffset)