|
18 | 18 | #include "../../cascadia/terminalcore/ITerminalApi.hpp" |
19 | 19 | #include "../../cascadia/terminalcore/ITerminalInput.hpp" |
20 | 20 |
|
| 21 | +#include <til/ticket_lock.h> |
| 22 | + |
21 | 23 | static constexpr std::wstring_view linkPattern{ LR"(\b(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|$!:,.;]*[A-Za-z0-9+&@#/%=~_|$])" }; |
22 | 24 | static constexpr size_t TaskbarMinProgress{ 10 }; |
23 | 25 |
|
@@ -77,8 +79,8 @@ class Microsoft::Terminal::Core::Terminal final : |
77 | 79 | // WritePastedText goes directly to the connection |
78 | 80 | void WritePastedText(std::wstring_view stringView); |
79 | 81 |
|
80 | | - [[nodiscard]] std::shared_lock<std::shared_mutex> LockForReading(); |
81 | | - [[nodiscard]] std::unique_lock<std::shared_mutex> LockForWriting(); |
| 82 | + [[nodiscard]] std::unique_lock<til::ticket_lock> LockForReading(); |
| 83 | + [[nodiscard]] std::unique_lock<til::ticket_lock> LockForWriting(); |
82 | 84 |
|
83 | 85 | short GetBufferHeight() const noexcept; |
84 | 86 |
|
@@ -244,6 +246,15 @@ class Microsoft::Terminal::Core::Terminal final : |
244 | 246 | std::function<void()> _pfnWarningBell; |
245 | 247 | std::function<void(std::wstring_view)> _pfnTitleChanged; |
246 | 248 | std::function<void(std::wstring_view)> _pfnCopyToClipboard; |
| 249 | + |
| 250 | + // I've specifically put this instance here as it requires |
| 251 | + // alignas(std::hardware_destructive_interference_size) |
| 252 | + // for best performance. |
| 253 | + // |
| 254 | + // But we can abuse the fact that the surrounding members rarely change and are huge |
| 255 | + // (std::function is like 64 bytes) to create some natural padding without wasting space. |
| 256 | + til::ticket_lock _readWriteLock; |
| 257 | + |
247 | 258 | std::function<void(const int, const int, const int)> _pfnScrollPositionChanged; |
248 | 259 | std::function<void(const til::color)> _pfnBackgroundColorChanged; |
249 | 260 | std::function<void()> _pfnCursorPositionChanged; |
@@ -299,8 +310,6 @@ class Microsoft::Terminal::Core::Terminal final : |
299 | 310 | SelectionExpansionMode _multiClickSelectionMode; |
300 | 311 | #pragma endregion |
301 | 312 |
|
302 | | - std::shared_mutex _readWriteLock; |
303 | | - |
304 | 313 | // TODO: These members are not shared by an alt-buffer. They should be |
305 | 314 | // encapsulated, such that a Terminal can have both a main and alt buffer. |
306 | 315 | std::unique_ptr<TextBuffer> _buffer; |
|
0 commit comments