mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-23 03:05:13 +08:00
rename reader_cancel_thread to reader_thread_job_is_stale, update comments
This commit is contained in:
parent
29fda9cb6c
commit
3f5c02bf92
@ -181,7 +181,7 @@ commence.
|
||||
*/
|
||||
#define SEARCH_FORWARD 1
|
||||
|
||||
/* Any time the contents of a buffer changes, we update the generation count. This allows for our background highlighting thread to notice it and skip doing work that it would otherwise have to do. */
|
||||
/* Any time the contents of a buffer changes, we update the generation count. This allows for our background highlighting thread to notice it and skip doing work that it would otherwise have to do. This variable should really be of some kind of interlocked or atomic type that guarantees we're not reading stale cache values. With C++11 we should use atomics, but until then volatile should work as well, at least on x86.*/
|
||||
static volatile unsigned int s_generation_count;
|
||||
|
||||
/* This pthreads generation count is set when an autosuggestion background thread starts up, so it can easily check if the work it is doing is no longer useful. */
|
||||
@ -671,7 +671,7 @@ int reader_reading_interrupted()
|
||||
return res;
|
||||
}
|
||||
|
||||
bool reader_cancel_thread()
|
||||
bool reader_thread_job_is_stale()
|
||||
{
|
||||
ASSERT_IS_BACKGROUND_THREAD();
|
||||
return (void*)(uintptr_t) s_generation_count != pthread_getspecific(generation_count_key);
|
||||
|
4
reader.h
4
reader.h
@ -137,10 +137,8 @@ int reader_reading_interrupted();
|
||||
generation count the current thread was started with.
|
||||
Note 1: currently only valid for autocompletion threads! Other threads don't
|
||||
set the threadlocal generation count when they start up.
|
||||
Note 2: This function uses conditional compilation for thread-local storage.
|
||||
If the compiler doesn't support that this function always returns `false`.
|
||||
*/
|
||||
bool reader_cancel_thread();
|
||||
bool reader_thread_job_is_stale();
|
||||
|
||||
/**
|
||||
Read one line of input. Before calling this function, reader_push()
|
||||
|
@ -728,7 +728,7 @@ static int wildcard_expand_internal(const wchar_t *wc,
|
||||
|
||||
// debug( 3, L"WILDCARD_EXPAND %ls in %ls", wc, base_dir );
|
||||
|
||||
if (is_main_thread() ? reader_interrupted() : reader_cancel_thread())
|
||||
if (is_main_thread() ? reader_interrupted() : reader_thread_job_is_stale())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user