Databases Reference
In-Depth Information
try {
monitor.beginTask(null, Policy.totalWork);
int depth = -1;
try {
depth =
return runInWorkspace(Policy.subMonitorFor(monitor,
Policy.opWork,
SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK));
} catch (OperationCanceledException e) {
return Status.CANCEL_STATUS;
} finally {
if (depth >= 0)
}
} catch (CoreException e) {
return e.getStatus();
} finally {
monitor.done();
}
FIGURE 7.4: Example of workspace operations and locking discipline usage
in class InternalWorkspaceJob in Eclipse.
method operationCanceled is called on the WorkManager of the current
workspace. As can be seen from the code in Figure 7.4, this pattern involves
error handling and may be quite tricky to get right. We have come across
this pattern by observing that pairs h beginOperation , endOperation i and
h beginUnprotected , endUnprotected i are both highly correlated in the code.
This pattern is easily described as a context-free language that allows nested
matching brackets, whose grammar is shown below. 3
S ! O ?
O ! w : prepareOperation ()
w : beginOperation ()
U ?
w : endOperation ()
3 S is the grammar start symbol and ? is used to represent 0 or more copies of the
preceding non-terminal; ? indicates that the preceding non-terminal is optional.
 
Search WWH ::




Custom Search