#ifndef _QMQUEUEH
#define _QMQUEUEH

#include "transmng.h"
#include "qmsockets.h"

typedef struct QMQ_item* QMQ_item_ptr;
struct QMQ_item{
  QM_message *item;      // the item is a QM_message
  // 250603
  //hot_uint32 thId;             // dcadena
                        // thread id, if -1 the petition
                        // is not of pgserver
  T_Transaction* trans;   // pointer to the transaction
  QMQ_item_ptr next;    // next item in the list
  QMQ_item_ptr prev;    // previous item in the list
};

typedef struct T_QMQueue* T_QMQueue_ptr;

struct T_QMQueue {
  QMQ_item_ptr first;
  QMQ_item_ptr last;
};

T_QMQueue_ptr QMQ_create();
bool QMQ_isEmpty(T_QMQueue_ptr);
void QMQ_print(T_QMQueue_ptr);
void QMQ_printR(T_QMQueue_ptr);
void QMQ_printFirstAndNumElements(T_QMQueue_ptr);
// 250603
// void QMQ_enqueue(T_QMQueue_ptr, QM_message, T_Transaction*, hot_uint32);
void QMQ_enqueue(T_QMQueue_ptr, QM_message*, T_Transaction*);
T_Transaction* QMQ_getFirst(T_QMQueue_ptr);
hot_uint32 QMQ_getFirstThId(T_QMQueue_ptr);
QM_message* QMQ_dequeue(T_QMQueue_ptr);
QM_message *QMQ_getFirstQM_message(T_QMQueue_ptr queue);
#endif
