[PR #652] [MERGED] Add batch writer for TextView's #1006

Closed
opened 2026-03-04 01:08:58 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/rivo/tview/pull/652
Author: @SamWhited
Created: 9/23/2021
Status: Merged
Merged: 10/29/2021
Merged by: @rivo

Base: masterHead: tview_writer


📝 Commits (2)

  • 4385df9 Add batch writer for TextView's
  • c0678d7 Fix race condition with locking in SetText

📊 Changes

2 files changed (+88 additions, -7 deletions)

View changed files

example_textview_test.go (+21 -0)
📝 textview.go (+67 -7)

📄 Description

I'd like to propose this as an alternative superset to #641 (See also discussion in #636).

This allows for backwards compatibility by not modifying the locking characteristics of Write, but also gives us a way to perform writes in a tight loop without incurring the overhead of locking.

Usage would look like this:

tv := tview.NewTextView()

w := tv.BatchWriter() // Lock acquired
defer w.Close() // Lock released
w.Clear()
for {
  w.Write(/* some long write, copy, etc. in a loop */)
}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/rivo/tview/pull/652 **Author:** [@SamWhited](https://github.com/SamWhited) **Created:** 9/23/2021 **Status:** ✅ Merged **Merged:** 10/29/2021 **Merged by:** [@rivo](https://github.com/rivo) **Base:** `master` ← **Head:** `tview_writer` --- ### 📝 Commits (2) - [`4385df9`](https://github.com/rivo/tview/commit/4385df9931b57b34fbbbb2708e4878275fb4704f) Add batch writer for TextView's - [`c0678d7`](https://github.com/rivo/tview/commit/c0678d7aa9a04e8cf1ebf187754179d47a83d224) Fix race condition with locking in SetText ### 📊 Changes **2 files changed** (+88 additions, -7 deletions) <details> <summary>View changed files</summary> ➕ `example_textview_test.go` (+21 -0) 📝 `textview.go` (+67 -7) </details> ### 📄 Description I'd like to propose this as an alternative superset to #641 (See also discussion in #636). This allows for backwards compatibility by not modifying the locking characteristics of `Write`, but also gives us a way to perform writes in a tight loop without incurring the overhead of locking. Usage would look like this: ```go tv := tview.NewTextView() w := tv.BatchWriter() // Lock acquired defer w.Close() // Lock released w.Clear() for { w.Write(/* some long write, copy, etc. in a loop */) } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 01:08:58 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#1006
No description provided.