package plugin import ( "container/list" ) func (obj *PluginObject) Get(k string) any { obj.taskDataLock.RLock() defer obj.taskDataLock.RUnlock() return obj.taskData[k] } func (obj *PluginObject) Set(k string, v any) { obj.taskDataLock.Lock() defer obj.taskDataLock.Unlock() obj.taskData[k] = v } func (obj *PluginObject) GetSet(k string, fn func(old any) any) { obj.taskDataLock.Lock() defer obj.taskDataLock.Unlock() obj.taskData[k] = fn(obj.taskData[k]) } func (obj *PluginObject) Remove(k string) { obj.taskDataLock.Lock() defer obj.taskDataLock.Unlock() delete(obj.taskData, k) } func (obj *PluginObject) Push(k string, v any) { obj.taskListLock.Lock() defer obj.taskListLock.Unlock() list1 := obj.taskList[k] if list1 == nil { list1 = list.New() obj.taskList[k] = list1 } obj.taskList[k].PushBack(v) } func (obj *PluginObject) Pop(k string) any { obj.taskListLock.RLock() list1 := obj.taskList[k] obj.taskListLock.RUnlock() if list1 == nil { return nil } obj.taskListLock.Lock() defer obj.taskListLock.Unlock() item := list1.Front() if item == nil { return nil } v := obj.taskList[k].Remove(item) return v } func (obj *PluginObject) CountList(k string) int { obj.taskListLock.RLock() defer obj.taskListLock.RUnlock() list1 := obj.taskList[k] if list1 == nil { return 0 } return list1.Len() } func (obj *PluginObject) RemoveList(k string) { obj.taskListLock.Lock() defer obj.taskListLock.Unlock() delete(obj.taskList, k) }