Neil Hodgson wrote:
I do not fully agree with you Neil. SciTEWin invokes
SciTEBase::Execute() only where there is a job ready to run. I would
think that if a second thread was going to start a job, the first one
running would block it
I was thinking of reentrance on the UI thread. User adds a command;
IDM_JOBS; SciTEBase::Execute; SendEditor(SCI_MARKERDELETEALL, 0);
SCN_SAVEPOINTLEFT notification; Lua script adds command and the UI
thread has two calls to SciTEBase::Execute on the stack at once,
leading to two tool threads and confusion. Moving the setting of
executing to before any calls that could leak control out stops that
but as a general rule its better to make access to thread sensitive
data highly protected.
The design I am planning for Lua scripts to adding commands would
(should?) not cause a second thread of SciTEBase::Execute(). The job
gets added to the queue and then the message is sent to the command
method. Since there is a job running nothing else happens.
There could be two calls to SciTEWin::Command() on the stack though.
Maybe I should move the variable 'executing' to the jobQueue class and
wrap it in locks.
I'll upload everything sometime later, but this is the re-worked
SciTEWin::Command() section:
case IDM_FINISHEDEXECUTE: {
executing = false;
Job* job = jobQueue.CurrentJob(); // job is now only visible
to this case block, the exitcode is visible to both
if (job) {
exitcode = job->exitcode;
}
if (job && exitcode == 0 && (job->flags & jobIsBuilding) ==
jobIsBuilding) {
// The build command is first command in a sequence so
it is only built if
// that command succeeds not if a second returns after
document is modified.
if (job->bufferPath.IsSet()) {
for (int i = 0; i < buffers.length; i++) {
if
(buffers.buffers[i].SameNameAs(job->bufferPath)) {
buffers.buffers[i].isBuilt = true;
}
}
}
}
}
case IDM_JOBS:
if ((cmdID == IDM_JOBS || cmdID == IDM_FINISHEDEXECUTE &&
exitcode == 0) && !executing && !jobQueue.IsEmpty()) {
SciTEBase::Execute();
_beginthread(ExecThread, 1024 * 1024, reinterpret_cast<void
*>(this));
} else if (cmdID == IDM_FINISHEDEXECUTE && exitcode != 0) {
if (needReadProperties) {
ReadProperties();
}
CheckMenus();
jobQueue.Clear(props);
CheckReload();
}
break;
April
--
Old age ain't no place for sissies.
-- Bette Davis
_______________________________________________
Scite-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scite-interest