mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-04 07:21:14 -03:00
Null notifier to support fishd synchronization, so we can select the
synchronization mechanism at runtime
This commit is contained in:
@@ -526,13 +526,3 @@ void env_universal_get_names(wcstring_list_t &lst,
|
||||
show_unexported);
|
||||
}
|
||||
|
||||
|
||||
bool synchronizes_via_fishd()
|
||||
{
|
||||
if (program_name && ! wcscmp(program_name, L"fishd"))
|
||||
{
|
||||
/* fishd always wants to use fishd */
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,4 @@ void env_universal_get_names(wcstring_list_t &list,
|
||||
*/
|
||||
void env_universal_barrier();
|
||||
|
||||
/* Temporary */
|
||||
bool synchronizes_via_fishd();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1900,8 +1900,18 @@ class universal_notifier_named_pipe_t : public universal_notifier_t
|
||||
}
|
||||
};
|
||||
|
||||
class universal_notifier_null_t : public universal_notifier_t
|
||||
{
|
||||
/* Does nothing! */
|
||||
};
|
||||
|
||||
static universal_notifier_t::notifier_strategy_t fetch_default_strategy_from_environment()
|
||||
{
|
||||
if (! synchronizes_via_fishd())
|
||||
{
|
||||
return universal_notifier_t::strategy_null;
|
||||
}
|
||||
|
||||
universal_notifier_t::notifier_strategy_t result = universal_notifier_t::strategy_default;
|
||||
|
||||
const struct
|
||||
@@ -1983,6 +1993,9 @@ universal_notifier_t *universal_notifier_t::new_notifier_for_strategy(universal_
|
||||
|
||||
case strategy_named_pipe:
|
||||
return new universal_notifier_named_pipe_t(test_path);
|
||||
|
||||
case strategy_null:
|
||||
return new universal_notifier_null_t();
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Unsupported strategy %d\n", strat);
|
||||
@@ -2022,3 +2035,23 @@ bool universal_notifier_t::notification_fd_became_readable(int fd)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool initialize_synchronizes_via_fishd()
|
||||
{
|
||||
const char *tmp = getenv("fish_use_fishd");
|
||||
return tmp != NULL && from_string<bool>(tmp);
|
||||
}
|
||||
|
||||
bool synchronizes_via_fishd()
|
||||
{
|
||||
if (program_name && ! wcscmp(program_name, L"fishd"))
|
||||
{
|
||||
/* fishd always wants to use fishd */
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Note that in general we can't change this once it's been set, so we only load it once */
|
||||
static bool result = initialize_synchronizes_via_fishd();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -302,7 +302,10 @@ class universal_notifier_t
|
||||
strategy_inotify,
|
||||
|
||||
// Strategy that uses notify(3). Simple and efficient, but OS X only.
|
||||
strategy_notifyd
|
||||
strategy_notifyd,
|
||||
|
||||
// Null notifier, does nothing
|
||||
strategy_null
|
||||
};
|
||||
|
||||
protected:
|
||||
@@ -343,6 +346,9 @@ class universal_notifier_t
|
||||
std::string get_machine_identifier();
|
||||
bool get_hostname_identifier(std::string *result);
|
||||
|
||||
/* Temporary */
|
||||
bool synchronizes_via_fishd();
|
||||
|
||||
/* Environment variable for requesting a particular universal notifier. See fetch_default_strategy_from_environment for names. */
|
||||
#define UNIVERSAL_NOTIFIER_ENV_NAME "fish_universal_notifier"
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ static wint_t readb()
|
||||
fd_max = maxi(fd_max, notifier_fd);
|
||||
}
|
||||
|
||||
/* Get the suggested delay (possibly none) */
|
||||
/* Get its suggested delay (possibly none) */
|
||||
struct timeval tv = {};
|
||||
const unsigned long usecs_delay = notifier.usec_delay_between_polls();
|
||||
if (usecs_delay > 0)
|
||||
|
||||
Reference in New Issue
Block a user