Navigation Menu

Skip to content

Commit

Permalink
executor experiments, std::atomic instead of Interlocked*()
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Apr 28, 2016
1 parent 69c0447 commit c97744c
Show file tree
Hide file tree
Showing 23 changed files with 121 additions and 190 deletions.
35 changes: 6 additions & 29 deletions far/FarEng.hlf.m4
Expand Up @@ -5502,16 +5502,15 @@ $ #far:config System.Executor.ExcludeCmds#

Изменение этого параметра возможно через ~far:config~@FarConfig@

@System.Executor.NotQuotedShell
$ #far:config System.Executor.NotQuotedShell#
При передаче строки командному процессору, она заключается в кавычки. Это необходимо для правильной работы CMD.EXE.
Параметр позволяет задать список командных процессоров, для которых строка в кавычки заключаться не будет. Имя командного процессора берётся из переменной среды %comspec%.
@System.Executor.ComspecArguments
$ #far:config System.Executor.ComspecArguments#

По умолчанию значение = "TCC.EXE;TCCLE.EXE".
Arguments for command processor. #{0}# is a placeholder for entire executing command.
If your processor uses differnt keys or quotes you can change it here.

В параметре можно использовать переменные среды.
Default value: #/S /C "{0}"# (compatible with cmd.exe)

Изменение этого параметра возможно через ~far:config~@FarConfig@
This parameter can be changed only via ~far:config~@FarConfig@

@System.Executor.FullTitle
$ #far:config System.Executor.FullTitle#
Expand All @@ -5536,28 +5535,6 @@ $ #far:config Interface.FormatNumberSeparators#

Изменение этого параметра возможно через ~far:config~@FarConfig@

@System.Executor.ComSpecParams
$ #far:config System.Executor.ComSpecParams#
Параметр позволяет задавать ключи для командного процессора при запуске внешних программ.

Перед запуском внешней программы Far Manager формирует строку запуска подобно следующему шаблону:

COMSPEC ComSpecParams Program ProgramParams

Здесь

COMSPEC - значение переменной среды %COMSPEC%
ComSpecParams - этот параметр (для cmd.exe это '/C ')
Program - запускаемая программа
ProgramParams - параметры запускаемой программы

По умолчанию значение = "/C"

Изменение этого параметра возможно через ~far:config~@FarConfig@

See also ~System.Executor.NotQuotedShell~@System.Executor.NotQuotedShell@,
~System.Executor.ExcludeCmds~@System.Executor.ExcludeCmds@

@System.Executor.BatchType
$ #far:config System.Executor.BatchType#
Параметр позволяет задавать список расширений файлов, по которым Far Manager будет различать какие
Expand Down
33 changes: 5 additions & 28 deletions far/FarRus.hlf.m4
Expand Up @@ -5624,14 +5624,13 @@ $ #far:config System.Executor.ExcludeCmds#

Изменение этого параметра возможно через ~far:config~@FarConfig@

@System.Executor.NotQuotedShell
$ #far:config System.Executor.NotQuotedShell#
При передаче строки командному процессору, она заключается в кавычки. Это необходимо для правильной работы CMD.EXE.
Параметр позволяет задать список командных процессоров, для которых строка в кавычки заключаться не будет. Имя командного процессора берётся из переменной среды %comspec%.
@System.Executor.ComspecArguments
$ #far:config System.Executor.ComspecArguments#

По умолчанию значение = "TCC.EXE;TCCLE.EXE".
Аргументы, передаваемые командному процессору. #{0}# заменяется непосредственно исполняемой командой.
Если ваш процессор использует другие ключи и/или кавычки, вы можете задать это здесь.

В параметре можно использовать переменные среды.
Значение по умолчанию: #/S /C "{0}"# (совместимо с cmd.exe)

Изменение этого параметра возможно через ~far:config~@FarConfig@

Expand All @@ -5658,28 +5657,6 @@ $ #far:config Interface.FormatNumberSeparators#

Изменение этого параметра возможно через ~far:config~@FarConfig@

@System.Executor.ComSpecParams
$ #far:config System.Executor.ComSpecParams#
Параметр позволяет задавать ключи для командного процессора при запуске внешних программ.

Перед запуском внешней программы Far Manager формирует строку запуска подобно следующему шаблону:

COMSPEC ComSpecParams Program ProgramParams

Здесь

COMSPEC - значение переменной среды %COMSPEC%
ComSpecParams - этот параметр (для cmd.exe это '/C ')
Program - запускаемая программа
ProgramParams - параметры запускаемой программы

По умолчанию значение = "/C"

Изменение этого параметра возможно через ~far:config~@FarConfig@

См. также ~System.Executor.NotQuotedShell~@System.Executor.NotQuotedShell@,
~System.Executor.ExcludeCmds~@System.Executor.ExcludeCmds@

@System.Executor.BatchType
$ #far:config System.Executor.BatchType#
Параметр позволяет задавать список расширений файлов, по которым Far Manager будет различать какие
Expand Down
6 changes: 3 additions & 3 deletions far/PluginA.hpp
Expand Up @@ -96,8 +96,8 @@ class PluginA: public Plugin
const char *GetMsgA(LNGID nID) const;

private:
virtual void Prologue() override { SetFileApisToOEM(); OEMApiCnt++; }
virtual void Epilogue() override { OEMApiCnt--; if(!OEMApiCnt) SetFileApisToANSI(); }
virtual void Prologue() override { Plugin::Prologue(); SetFileApisToOEM(); ++OEMApiCnt; }
virtual void Epilogue() override { Plugin::Epilogue(); --OEMApiCnt; if(!OEMApiCnt) SetFileApisToANSI(); }

void FreePluginInfo();
void ConvertPluginInfo(const oldfar::PluginInfo &Src, PluginInfo *Dest);
Expand All @@ -110,7 +110,7 @@ class PluginA: public Plugin
oldfar::PluginPanelItem *pFDPanelItemA;
oldfar::PluginPanelItem *pVFDPanelItemA;

UINT64 OEMApiCnt;
std::atomic_ulong OEMApiCnt;

bool opif_shortcut;
std::unique_ptr<file_version> FileVersion;
Expand Down
12 changes: 11 additions & 1 deletion far/changelog
@@ -1,4 +1,14 @@
zg 28.04.2016 13:20:04 +0200 - build 4643
drkns 28.04.2016 16:47:33 +0200 - build 4644

1. Продолжение экспериментальных изменений в запускателе:
- System.Executor.NotQuotedShell и System.Executor.ComSpecParams больше нет. Однако, теперь есть System.Executor.ComspecArguments, управляющий одновременно и ключами, и кавычками.
По умолчанию значение совместимо с cmd.exe - /S /C "{0}", где {0} будет заменено исполняемой командой.
Для bash замените на -c '{0}', для tcc - на -с {0}
- (частично) #0003223: при передаче в comspec разворачивалось больше, чем нужно.

2. Используем std::atomic<T> вместо Interlocked*().

zg 28.04.2016 13:20:04 +0200 - build 4643

1. в комбобоксе не срабатывал хоткей для текущего элемента.

Expand Down
6 changes: 3 additions & 3 deletions far/cmdline.cpp
Expand Up @@ -436,7 +436,7 @@ int CommandLine::ProcessKey(const Manager::Key& Key)
Info.Command = strStr;
Info.WaitMode = Info.no_wait;
Info.NewWindow = IsNewWindow;
Info.DirectRun = false;
Info.ExecMode = Info.detect;
Info.RunAs = IsRunAs;

SetString(L"", false);
Expand Down Expand Up @@ -851,7 +851,7 @@ void CommandLine::ShowViewEditHistory()
Info.Command = strStr;
Info.WaitMode = Type == HR_EXTERNAL_WAIT? Info.wait_finish : Info.no_wait;
Info.NewWindow = false;
Info.DirectRun = false;
Info.ExecMode = Info.detect;
Info.RunAs = false;

ExecString(Info);
Expand Down Expand Up @@ -1053,7 +1053,7 @@ void CommandLine::ExecString(execute_info& Info)

FarChDir(m_CurDir);

if (!Info.DirectRun)
if (Info.ExecMode != Info.direct)
{
if (!Info.Command.empty() && Info.Command[0] == L'@')
{
Expand Down
3 changes: 2 additions & 1 deletion far/cmdline.hpp
Expand Up @@ -41,11 +41,12 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
struct execute_info
{
enum wait_mode { no_wait, wait_idle, wait_finish };
enum exec_mode { detect, direct, external };

string Command;
wait_mode WaitMode;
bool NewWindow;
bool DirectRun;
exec_mode ExecMode;
bool RunAs;
};

Expand Down
5 changes: 2 additions & 3 deletions far/config.cpp
Expand Up @@ -1805,8 +1805,7 @@ void Options::InitConfigData()
{FSSF_PRIVATE, NKeySystemExecutor,L"RestoreCP", OPT_DEF(Exec.RestoreCPAfterExecute, true)},
{FSSF_PRIVATE, NKeySystemExecutor,L"UseAppPath", OPT_DEF(Exec.ExecuteUseAppPath, true)},
{FSSF_PRIVATE, NKeySystemExecutor,L"UseHomeDir", OPT_DEF(Exec.UseHomeDir, true)},
{FSSF_PRIVATE, NKeySystemExecutor,L"NotQuotedShell", OPT_DEF(Exec.strNotQuotedShell, L"TCC.EXE;TCCLE.EXE")},
{FSSF_PRIVATE, NKeySystemExecutor,L"ComSpecParams", OPT_DEF(Exec.strComSpecParams, L"/C")},
{FSSF_PRIVATE, NKeySystemExecutor,L"ComspecFormat", OPT_DEF(Exec.ComspecArguments, L"/S /C \"{0}\"")},

{FSSF_PRIVATE, NKeyViewer,L"AutoDetectCodePage", OPT_DEF(ViOpt.AutoDetectCodePage, true)},
{FSSF_PRIVATE, NKeyViewer,L"DefaultCodePage", OPT_DEF(ViOpt.DefaultCodePage, GetACP())},
Expand Down Expand Up @@ -3036,7 +3035,7 @@ void Options::ShellOptions(bool LastCommand, const MOUSE_EVENT_RECORD *MouseEven
}
}

int CurrentWindowType = Global->WindowManager->GetCurrentWindow()->GetType();
const auto CurrentWindowType = Global->WindowManager->GetCurrentWindow()->GetType();
// TODO:Здесь как то нужно изменить, чтобы учесть будущие новые типы полноэкранных окон
// или то, что, скажем редактор/вьювер может быть не полноэкранным

Expand Down
3 changes: 1 addition & 2 deletions far/config.hpp
Expand Up @@ -600,10 +600,9 @@ class Options: noncopyable
BoolOption ExecuteFullTitle;
StringOption strExecuteBatchType;
StringOption strExcludeCmds;
StringOption strComSpecParams;
StringOption ComspecArguments;
BoolOption UseHomeDir; // cd ~
StringOption strHomeDir; // cd ~
StringOption strNotQuotedShell;
};

palette Palette;
Expand Down
10 changes: 7 additions & 3 deletions far/dialog.cpp
Expand Up @@ -4301,12 +4301,14 @@ void Dialog::Process()

if (m_ExitCode == -1)
{
static LONG in_dialog = -1;
static std::atomic_long DialogsCount(0);
clock_t btm = 0;
long save = 0;
DialogMode.Set(DMODE_BEGINLOOP);

if (!InterlockedIncrement(&in_dialog))
++DialogsCount;

if (DialogsCount == 1)
{
btm = clock();
save = WaitUserTime;
Expand All @@ -4317,7 +4319,9 @@ void Dialog::Process()
Global->WindowManager->ExecuteModal(shared_from_this());
save += (clock() - btm);

if (InterlockedDecrement(&in_dialog) == -1)
--DialogsCount;

if (!DialogsCount)
WaitUserTime = save;
}

Expand Down
6 changes: 3 additions & 3 deletions far/elevation.hpp
Expand Up @@ -73,8 +73,8 @@ class elevation: noncopyable
class suppress: noncopyable
{
public:
suppress(): m_owner(Global? Global->Elevation : nullptr) { if (m_owner) InterlockedIncrement(&m_owner->m_suppressions); }
~suppress() { if (m_owner) InterlockedDecrement(&m_owner->m_suppressions); }
suppress(): m_owner(Global? Global->Elevation : nullptr) { if (m_owner) ++m_owner->m_suppressions; }
~suppress() { if (m_owner) --m_owner->m_suppressions; }

private:
elevation* m_owner;
Expand All @@ -91,7 +91,7 @@ class elevation: noncopyable
bool Initialize();
bool ElevationApproveDlg(LNGID Why, const string& Object);

volatile long m_suppressions;
std::atomic_ulong m_suppressions;
os::handle m_pipe;
os::handle m_process;
os::handle m_job;
Expand Down

0 comments on commit c97744c

Please sign in to comment.