mirror of
https://github.com/romkatv/powerlevel10k.git
synced 2025-02-16 15:54:29 +01:00
remove explicit timeout support from worker
This commit is contained in:
parent
da498aef57
commit
a6e0b01dc1
2 changed files with 47 additions and 79 deletions
|
@ -4500,7 +4500,6 @@ function _p9k_maybe_dump() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _p9k_on_expand() {
|
function _p9k_on_expand() {
|
||||||
_p9k__last_prompt_update_time=EPOCHREALTIME
|
|
||||||
(( _p9k__expanded && ! $+__p9k_instant_prompt_active )) && return
|
(( _p9k__expanded && ! $+__p9k_instant_prompt_active )) && return
|
||||||
|
|
||||||
() {
|
() {
|
||||||
|
@ -4897,7 +4896,6 @@ typeset -g _p9k__param_pat
|
||||||
typeset -g _p9k__param_sig
|
typeset -g _p9k__param_sig
|
||||||
|
|
||||||
_p9k_init_vars() {
|
_p9k_init_vars() {
|
||||||
typeset -gF _p9k__last_prompt_update_time
|
|
||||||
typeset -ga _p9k_show_on_command
|
typeset -ga _p9k_show_on_command
|
||||||
typeset -g _p9k__last_buffer
|
typeset -g _p9k__last_buffer
|
||||||
typeset -ga _p9k__last_commands
|
typeset -ga _p9k__last_commands
|
||||||
|
|
|
@ -1,61 +1,56 @@
|
||||||
# invoked in worker: _p9k_worker_main <timeout>
|
# invoked in worker: _p9k_worker_main <timeout>
|
||||||
function _p9k_worker_main() {
|
function _p9k_worker_main() {
|
||||||
zmodload zsh/system || return
|
zmodload zsh/system || return
|
||||||
zmodload zsh/zselect || return
|
zmodload zsh/zselect || return
|
||||||
zselect -t0
|
zmodload zsh/datetime || return
|
||||||
(( $? == 1 )) || return
|
! { zselect -t0 || (( $? != 1 )) } || return
|
||||||
|
|
||||||
local req fd
|
local req fd
|
||||||
local -A inflight # fd => id$'\x1f'sync
|
|
||||||
local -a ready
|
local -a ready
|
||||||
local _p9k_worker_tmout # empty or non-negative int, in hundredths of a second
|
local -A inflight # fd => id$'\x1f'sync
|
||||||
while true; do
|
local -ri _p9k_worker_runs_me=1
|
||||||
if zselect -a ready ${_p9k_worker_tmout:+-t$_p9k_worker_tmout} 0 ${(k)inflight}; then
|
while zselect -a ready 0 ${(k)inflight}; do
|
||||||
[[ $ready[1] == -r ]] || return
|
[[ $ready[1] == -r ]] || return
|
||||||
for fd in ${ready:1}; do
|
for fd in ${ready:1}; do
|
||||||
if [[ $fd == 0 ]]; then
|
if [[ $fd == 0 ]]; then
|
||||||
local buf=
|
local buf=
|
||||||
while true; do
|
while true; do
|
||||||
sysread -t 0 'buf[$#buf+1]' && continue
|
sysread -t 0 'buf[$#buf+1]' && continue
|
||||||
(( $? == 4 )) || return
|
(( $? == 4 )) || return
|
||||||
[[ $buf[-1] == (|$'\x1e') ]] && break
|
[[ $buf[-1] == (|$'\x1e') ]] && break
|
||||||
sysread 'buf[$#buf+1]' || return
|
sysread 'buf[$#buf+1]' || return
|
||||||
done
|
done
|
||||||
for req in ${(ps:\x1e:)buf}; do
|
for req in ${(ps:\x1e:)buf}; do
|
||||||
local parts=("${(@ps:\x1f:)req}") # id cond async sync
|
local parts=("${(@ps:\x1f:)req}") # id cond async sync
|
||||||
if () { eval $parts[2] }; then
|
if () { eval $parts[2] }; then
|
||||||
if [[ -n $parts[3] ]]; then
|
if [[ -n $parts[3] ]]; then
|
||||||
sysopen -r -o cloexec -u fd <(
|
sysopen -r -o cloexec -u fd <(
|
||||||
local REPLY=; eval $parts[3]; print -rn -- $REPLY) || return
|
local REPLY=; eval $parts[3]; print -rn -- $REPLY) || return
|
||||||
inflight[$fd]=$parts[1]$'\x1f'$parts[4]
|
inflight[$fd]=$parts[1]$'\x1f'$parts[4]
|
||||||
continue
|
continue
|
||||||
fi
|
|
||||||
local REPLY=
|
|
||||||
() { eval $parts[4] }
|
|
||||||
fi
|
fi
|
||||||
if [[ -n $parts[1] ]]; then
|
local REPLY=
|
||||||
print -rn -- d$parts[1]$'\x1e' || return
|
() { eval $parts[4] }
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
else
|
|
||||||
local REPLY=
|
|
||||||
while true; do
|
|
||||||
sysread -i $fd 'REPLY[$#REPLY+1]' && continue
|
|
||||||
(( $? == 5 )) || return
|
|
||||||
break
|
|
||||||
done
|
|
||||||
local parts=("${(@ps:\x1f:)inflight[$fd]}") # id sync
|
|
||||||
() { eval $parts[2] }
|
|
||||||
if [[ -n $parts[1] ]]; then
|
if [[ -n $parts[1] ]]; then
|
||||||
print -rn -- d$parts[1]$'\x1e' || return
|
print -rn -- d$parts[1]$'\x1e' || return
|
||||||
fi
|
fi
|
||||||
unset "inflight[$fd]"
|
done
|
||||||
|
else
|
||||||
|
local REPLY=
|
||||||
|
while true; do
|
||||||
|
sysread -i $fd 'REPLY[$#REPLY+1]' && continue
|
||||||
|
(( $? == 5 )) || return
|
||||||
|
break
|
||||||
|
done
|
||||||
|
local parts=("${(@ps:\x1f:)inflight[$fd]}") # id sync
|
||||||
|
() { eval $parts[2] }
|
||||||
|
if [[ -n $parts[1] ]]; then
|
||||||
|
print -rn -- d$parts[1]$'\x1e' || return
|
||||||
fi
|
fi
|
||||||
done
|
unset "inflight[$fd]"
|
||||||
else
|
fi
|
||||||
(( $? == 1 )) || return
|
done
|
||||||
(( $+functions[_p9k_worker_on_timeout] )) && _p9k_worker_on_timeout
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,17 +72,6 @@ function _p9k_worker_reply() { eval $1 }
|
||||||
# usage: _p9k_worker_reply <list>
|
# usage: _p9k_worker_reply <list>
|
||||||
function _p9k_worker_reply_remote() { print -rn -- e$1$'\x1e' }
|
function _p9k_worker_reply_remote() { print -rn -- e$1$'\x1e' }
|
||||||
|
|
||||||
# invoked in worker: _p9k_worker_on_timeout
|
|
||||||
function _p9k_worker_on_timeout() {
|
|
||||||
_p9k_worker_tmout=
|
|
||||||
_p9k_worker_reply _p9k_worker_keep_alive
|
|
||||||
}
|
|
||||||
|
|
||||||
# invoked in master: _p9k_worker_keep_alive
|
|
||||||
function _p9k_worker_keep_alive() {
|
|
||||||
_p9k_worker_invoke "" "_p9k_worker_tmout=100" "" ""
|
|
||||||
}
|
|
||||||
|
|
||||||
# invoked in master: _p9k_worker_send_params [param]...
|
# invoked in master: _p9k_worker_send_params [param]...
|
||||||
function _p9k_worker_send_params() {
|
function _p9k_worker_send_params() {
|
||||||
[[ -z $_p9k__worker_resp_fd || $# == 0 ]] && return
|
[[ -z $_p9k__worker_resp_fd || $# == 0 ]] && return
|
||||||
|
@ -197,16 +181,9 @@ function _p9k_worker_receive() {
|
||||||
print -r -- "
|
print -r -- "
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
setopt no_hist_expand extended_glob no_prompt_bang prompt_percent prompt_subst no_aliases
|
setopt no_hist_expand extended_glob no_prompt_bang prompt_percent prompt_subst no_aliases
|
||||||
zmodload zsh/system
|
|
||||||
zmodload zsh/datetime
|
|
||||||
function _p9k_worker_main() { $functions[_p9k_worker_main] }
|
function _p9k_worker_main() { $functions[_p9k_worker_main] }
|
||||||
function _p9k_worker_reply() { $functions[_p9k_worker_reply_remote] }" || return
|
function _p9k_worker_reply() { $functions[_p9k_worker_reply_remote] }
|
||||||
if (( _POWERLEVEL9K_EXPERIMENTAL_TIME_REALTIME )); then
|
_p9k_worker_main"$'\x1e' || return
|
||||||
print -r -- "function _p9k_worker_on_timeout() {
|
|
||||||
$functions[_p9k_worker_on_timeout] }" || return
|
|
||||||
fi
|
|
||||||
print -r -- "_p9k_worker_main" || return
|
|
||||||
print -rn -- $'\x1e' || return
|
|
||||||
if (( $#_p9k__worker_params )); then
|
if (( $#_p9k__worker_params )); then
|
||||||
print -rn -- $'\x1f' || return
|
print -rn -- $'\x1f' || return
|
||||||
typeset -p -- $_p9k__worker_params || return
|
typeset -p -- $_p9k__worker_params || return
|
||||||
|
@ -224,7 +201,6 @@ function _p9k_worker_receive() {
|
||||||
done
|
done
|
||||||
_p9k__worker_request_queue=()
|
_p9k__worker_request_queue=()
|
||||||
} >&$_p9k__worker_req_fd
|
} >&$_p9k__worker_req_fd
|
||||||
(( _POWERLEVEL9K_EXPERIMENTAL_TIME_REALTIME )) && _p9k_worker_keep_alive
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
return 1
|
return 1
|
||||||
|
@ -232,11 +208,7 @@ function _p9k_worker_receive() {
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if (( reset ||
|
(( reset )) && _p9k_reset_prompt
|
||||||
_POWERLEVEL9K_EXPERIMENTAL_TIME_REALTIME &&
|
|
||||||
_p9k__last_prompt_update_time < EPOCHREALTIME - 0.8 )); then
|
|
||||||
_p9k_reset_prompt
|
|
||||||
fi
|
|
||||||
return 0
|
return 0
|
||||||
} always {
|
} always {
|
||||||
(( $? )) && _p9k_worker_stop
|
(( $? )) && _p9k_worker_stop
|
||||||
|
@ -281,14 +253,12 @@ function _p9k_worker_start() {
|
||||||
|
|
||||||
# todo: remove
|
# todo: remove
|
||||||
function _p9k_reset_prompt() {
|
function _p9k_reset_prompt() {
|
||||||
zle && zle reset-prompt && zle -R && _p9k__last_prompt_update_time=EPOCHREALTIME
|
zle && zle reset-prompt && zle -R
|
||||||
}
|
}
|
||||||
|
|
||||||
emulate -L zsh -o prompt_subst # -o xtrace
|
emulate -L zsh -o prompt_subst # -o xtrace
|
||||||
|
|
||||||
POWERLEVEL9K_WORKER_LOG_LEVEL=DEBUG
|
POWERLEVEL9K_WORKER_LOG_LEVEL=DEBUG
|
||||||
_POWERLEVEL9K_EXPERIMENTAL_TIME_REALTIME=0
|
|
||||||
typeset -F _p9k__last_prompt_update_time
|
|
||||||
|
|
||||||
zmodload zsh/datetime
|
zmodload zsh/datetime
|
||||||
zmodload zsh/system
|
zmodload zsh/system
|
||||||
|
|
Loading…
Reference in a new issue