sequential_batch_queue.go ×5

Frontier kind: Code frontier

unlabeled · c_a08992fc04f3

5 tests · 2729 LOC · 135 files · introduces 0 tests · 31 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
5 ranges31 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
402 ranges2729 lines · 135 files · Browse complete extent
All tests (intent)
5 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 31 introduced LOC across 5 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/replication/sequential_batch_queue.go 31 introduced LOC · 5 ranges

Open complete file

54 // Add will try to batch input task with the last task in the queue. Since most likely incoming task
55 // are ordered by task ID, we only try to batch incoming task with last task in the queue.
56 > func (q *SequentialBatchableTaskQueue) Add(task TrackableExecutableTask) { sequential_batch_queue.go
57 > q.Lock()
58 > defer q.Unlock()
59 >
60 > if q.lastTask != nil && q.lastTask.AddTask(task) {
61 return
62 }
63
64 > incomingTask := q.createBatchedTask(task) sequential_batch_queue.go
65 > q.taskQueue.Add(incomingTask)
66 > q.updateLastTask(incomingTask)
67 }
68
69 > func (q *SequentialBatchableTaskQueue) Remove() (task TrackableExecutableTask) { sequential_batch_queue.go
70 > q.Lock()
71 > defer q.Unlock()
72 > taskToRemove := q.taskQueue.Remove()
73 > if taskToRemove == q.lastTask {
74 > q.lastTask = nil
75 > }
76 > return taskToRemove
77 }
78
89 }
90
91 > func (q *SequentialBatchableTaskQueue) updateLastTask(task *batchedTask) { sequential_batch_queue.go
92 > if q.lastTask == nil || sequentialBatchableTaskQueueCompareLess(q.lastTask, task) {
93 > q.lastTask = task
94 > }
95 }
96
97 > func (q *SequentialBatchableTaskQueue) createBatchedTask(task TrackableExecutableTask) *batchedTask { sequential_batch_queue.go
98 > return &batchedTask{
99 > batchedTask: task,
100 > individualTasks: []TrackableExecutableTask{task},
101 > state: batchStateOpen,
102 >
103 > // This is to add individual task back to this queue, so it can be processed again. This is based on an assumption: only one thread is
104 > // interacting with the queue. And this is a shortcut because a proper way is to resubmit the individual tasks back to scheduler.
105 > // But that requires a refactor on scheduler and task lifecycle and could be risky to included in this feature implementation.
106 > //
107 > individualTaskHandler: func(task TrackableExecutableTask) {
108 q.Add(task)
109 },