#ifndef TRI_TCI_CALL_STACK_H
#define TRI_TCI_CALL_STACK_H
#include "TriTciCallData.h"
#include "ArrayItemList.h"

#ifndef _WIN32
#include <pthread.h>
#endif

typedef struct TriTciCallStackRegister
{
#ifdef _WIN32
	void * hLock;
#else
	pthread_mutex_t mtxLock;
#endif
	Array* mStacks;
}TriTciCallStackRegister;

void initCallStackRegister(TriTciCallStackRegister * csr);
TriTciCallData * registerCall(TriTciCallStackRegister *csr, char* pData, int requiredAck, int nWaitingTime);
int acceptMessage(TriTciCallStackRegister *csr, AbstractTriTciMessage *msg);
int saveRemoteId(TriTciCallStackRegister *csr, int nRemoteId, int nLocalId);
void fillCommunicationIds(TriTciCallStackRegister *csr, char * pData, int bPop);
void onAck(TriTciCallStackRegister *csr, int nLocalId);
void unregisterProc(TriTciCallStackRegister *csr, TriTciCallDataStack* stack, int nLocalId);
void unregisterCall(TriTciCallStackRegister *csr);
void clear(TriTciCallStackRegister *csr);
void disposeCallStackRegister(TriTciCallStackRegister * csr);
#endif
