Ejemplo n.º 1
0
Msg *
MsgList::alloc(DxMessageCode code_, int32_t activityId_, void *data_,
		int32_t len_, MemBlk *blk_, MsgDataType dataType_)
{
	Msg *msg;
	SseInterfaceHeader hdr;

	lock();
	if (msgList.empty()) {
		Debug(DEBUG_MSGLIST, allocs, "allocs");
		Debug(DEBUG_MSGLIST, frees, "frees");
		unlock();
		Fatal(ERR_NMA);
	}

	msg = msgList.front();
	msgList.pop_front();

	Assert(!msg->allocated());
	msg->setAllocated();

	hdr.code = code_;
	hdr.activityId = activityId_;
	GetNssDate(hdr.timestamp);
	hdr.messageNumber = GetNextMsg();
	msg->setHeader(hdr);
	msg->setData(data_, len_, blk_, dataType_);

	++allocs;
	unlock();
	return (msg);
}