Last active
August 29, 2015 14:25
-
-
Save soheilhy/ef7b04d220a2b57e5629 to your computer and use it in GitHub Desktop.
Task ring buffer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TaskRing is an efficient, gob-compatible ring buffer for Tasks. | |
// TaskRing always wastes one element. | |
type TaskRing struct { | |
... | |
Stats Stats | |
} | |
// Stats represents the statistics of the task ring buffer. | |
type Stats struct { | |
Deque uint64 // Deque represents the total nubmer of dequeued tasks. | |
Enque uint64 // Enque represents the total nubmer of enqued tasks. | |
... | |
} | |
// Enque enqueues a task in the ring buffer. | |
func (r *TaskRing) Enque(t Task) {...} | |
// Deque dequeues a task from the ring. | |
func (r *TaskRing) Deque() (t Task, ok bool) {...} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment