InfiniSQL  v0.1.2-alpha
Massive Scale Transaction Processing
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MboxProducer Class Reference

mailbox producer More...

#include <Mbox.h>

Collaboration diagram for MboxProducer:

Public Member Functions

 MboxProducer ()
 
 MboxProducer (class Mbox *mboxarg, int16_t nodeidarg)
 create mailbox producer More...
 
virtual ~MboxProducer ()
 
void sendMsg (class Message &msgsnd)
 produce Message onto mailbox More...
 

Public Attributes

class Mboxmbox
 
int16_t nodeid
 
class MessageBatchSerializedobBatchMsg
 
class Mboxesmboxes
 

Friends

class Mboxes
 

Detailed Description

mailbox producer

Definition at line 108 of file Mbox.h.

Constructor & Destructor Documentation

MboxProducer::MboxProducer ( )

Definition at line 125 of file Mbox.cc.

125  : mbox(NULL), obBatchMsg(NULL)
126 {
127 }
MboxProducer::MboxProducer ( class Mbox mboxarg,
int16_t  nodeidarg 
)

create mailbox producer

Parameters
mboxargMbox to put Message object onto
nodeidargnodeid

Definition at line 129 of file Mbox.cc.

129  :
130  mbox(mboxarg), nodeid(nodeidarg), obBatchMsg(NULL)
131 {
132 }
MboxProducer::~MboxProducer ( )
virtual

Definition at line 134 of file Mbox.cc.

135 {
136 }

Member Function Documentation

void MboxProducer::sendMsg ( class Message msgsnd)

produce Message onto mailbox

Parameters
msgsndMessage

Definition at line 138 of file Mbox.cc.

References Mbox::counter, Message::message_s::destAddr, Mbox::getInt128FromPointer(), Mbox::getPtr(), mbox, mboxes, Message::messageStruct, MessageBatchSerialized::msgbatch, Message::nextmsg, MessageBatchSerialized::nmsgs, Topology::addressStruct::nodeid, nodeid, obBatchMsg, OBGWMSGBATCHSIZE, Mboxes::sendObBatch(), Message::sermsg(), and Mbox::tail.

Referenced by Listener::Listener(), Mboxes::sendObBatch(), Mboxes::toActor(), and Mboxes::toPartition().

139 {
140  class Message *msgptr;
141  if (nodeid != msgsnd.messageStruct.destAddr.nodeid)
142  { // must be sending to obgw then, so serialize here
143  if (obBatchMsg==NULL)
144  {
145  obBatchMsg=new class MessageBatchSerialized(nodeid);
146  }
148  {msgsnd.messageStruct.destAddr.nodeid, msgsnd.sermsg()};
149  delete &msgsnd;
151  {
152  mboxes->sendObBatch();
153  }
154  return;
155  }
156  else
157  {
158  msgptr=&msgsnd;
159  }
160  class Message &msg=*msgptr;
161 
162  msg.nextmsg = Mbox::getInt128FromPointer(NULL, 5555);
163 
164  __int128 mytail;
165  __int128 mynext;
166 
167  while (1)
168  {
169  mytail = __atomic_load_n(&mbox->tail, __ATOMIC_SEQ_CST);
170  mynext = __atomic_load_n(&(Mbox::getPtr(mytail)->nextmsg),
171  __ATOMIC_SEQ_CST);
172 
173  if (mytail == __atomic_load_n(&mbox->tail, __ATOMIC_SEQ_CST))
174  {
175  if (Mbox::getPtr(mynext) == NULL)
176  {
177  if (__atomic_compare_exchange_n(&(Mbox::getPtr(mytail)->nextmsg), &mynext, Mbox::getInt128FromPointer(&msg, __atomic_add_fetch(&mbox->counter, 1, __ATOMIC_SEQ_CST)), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST))
178  {
179  break;
180  }
181  }
182  else
183  {
184  // CAS(&Q->Tail, tail, <next.ptr, tail.count+1>)
185  __atomic_compare_exchange_n(&mbox->tail, &mytail, Mbox::getInt128FromPointer(Mbox::getPtr(mynext), __atomic_add_fetch(&mbox->counter, 1, __ATOMIC_SEQ_CST)), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
186  }
187  }
188  }
189 
190  __atomic_compare_exchange_n(&mbox->tail, &mytail, Mbox::getInt128FromPointer(&msg, __atomic_add_fetch(&mbox->counter, 1, __ATOMIC_SEQ_CST)), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
191 }

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

friend class Mboxes
friend

Definition at line 132 of file Mbox.h.

Member Data Documentation

class Mbox* MboxProducer::mbox

Definition at line 127 of file Mbox.h.

Referenced by Mboxes::Mboxes(), and sendMsg().

class Mboxes* MboxProducer::mboxes

Definition at line 130 of file Mbox.h.

Referenced by sendMsg().

int16_t MboxProducer::nodeid

Definition at line 128 of file Mbox.h.

Referenced by sendMsg().

class MessageBatchSerialized* MboxProducer::obBatchMsg

Definition at line 129 of file Mbox.h.

Referenced by sendMsg(), and Mboxes::sendObBatch().


The documentation for this class was generated from the following files: