+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type TransactionIf interface {
+ String() string
+ Release()
+ SendEvent(interface{}, time.Duration) (bool, bool)
+ WaitEvent(time.Duration) (interface{}, bool)
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+
+type Transaction struct {
+ mutex sync.Mutex //
+ Seq uint64 //transaction sequence
+ tracker *Tracker //tracker instance
+ Meid *xapp.RMRMeid //meid transaction related
+ ReqId RequestId //
+ Mtype int //Encoded message type to be send
+ Payload *e2ap.PackedData //Encoded message to be send
+ EventChan chan interface{}
+}
+
+func (t *Transaction) String() string {
+ return "trans(" + strconv.FormatUint(uint64(t.Seq), 10) + "/" + t.Meid.RanName + "/" + t.ReqId.String() + ")"
+}
+
+func (t *Transaction) SendEvent(event interface{}, waittime time.Duration) (bool, bool) {
+ if waittime > 0 {
+ select {
+ case t.EventChan <- event:
+ return true, false
+ case <-time.After(waittime):
+ return false, true
+ }
+ return false, false
+ }
+ t.EventChan <- event
+ return true, false
+}
+
+func (t *Transaction) WaitEvent(waittime time.Duration) (interface{}, bool) {
+ if waittime > 0 {
+ select {
+ case event := <-t.EventChan:
+ return event, false
+ case <-time.After(waittime):
+ return nil, true
+ }
+ }
+ event := <-t.EventChan
+ return event, false
+}
+
+func (t *Transaction) GetReqId() *RequestId {
+ t.mutex.Lock()
+ defer t.mutex.Unlock()
+ return &t.ReqId
+}
+
+func (t *Transaction) GetMtype() int {
+ t.mutex.Lock()
+ defer t.mutex.Unlock()
+ return t.Mtype
+}
+
+func (t *Transaction) GetMeid() *xapp.RMRMeid {
+ t.mutex.Lock()
+ defer t.mutex.Unlock()
+ if t.Meid != nil {
+ return t.Meid
+ }
+ return nil
+}
+
+func (t *Transaction) GetPayload() *e2ap.PackedData {
+ t.mutex.Lock()
+ defer t.mutex.Unlock()
+ return t.Payload
+}
+
+//-----------------------------------------------------------------------------
+//
+//-----------------------------------------------------------------------------
+type TransactionSubs struct {
+ Transaction //
+}
+
+func (t *TransactionSubs) String() string {
+ return "transsubs(" + t.Transaction.String() + ")"
+}
+
+func (t *TransactionSubs) Release() {
+ t.mutex.Lock()
+ xapp.Logger.Debug("RELEASE %s", t.String())
+ t.tracker = nil
+ t.mutex.Unlock()
+}
+