src/Doc/System/Server.thy
author wenzelm
Mon, 19 Mar 2018 19:24:45 +0100
changeset 67904 465f43a9f780
child 67917 d13b2dd20f5e
permissions -rw-r--r--
documentation for the Isabelle server;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
67904
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
     1
(*:maxLineLen=78:*)
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
     2
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
     3
theory Server
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
     4
imports Base
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
     5
begin
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
     6
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
     7
chapter \<open>The Isabelle server\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
     8
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
     9
text \<open>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    10
  An Isabelle session requires at least two processes, which are both rather
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    11
  heavy: Isabelle/Scala for the system infrastructure and Isabelle/ML for the
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    12
  logic session (e.g.\ HOL). In principle, these processes can be invoked
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    13
  directly on the command-line, e.g.\ via @{tool java}, @{tool scala}, @{tool
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    14
  process}, @{tool console}, but this approach is inadequate for reactive
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    15
  applications that require quick responses from the prover.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    16
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    17
  In contrast, the Isabelle server exposes Isabelle/Scala as a
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    18
  ``terminate-stay-resident'' application that manages multiple logic
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    19
  \<^emph>\<open>sessions\<close> and concurrent tasks to use \<^emph>\<open>theories\<close>. This provides an
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    20
  analogous to @{ML Thy_Info.use_theories} in Isabelle/ML, but with full
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    21
  concurrency and Isabelle/PIDE markup.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    22
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    23
  The client/server arrangement via TCP sockets also opens possibilities for
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    24
  remote Isabelle services that are accessed by local applications, e.g.\ via
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    25
  an SSH tunnel.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    26
\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    27
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    28
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    29
section \<open>Command-line tools\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    30
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    31
subsection \<open>Server \label{sec:tool-server}\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    32
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    33
text \<open>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    34
  The @{tool_def server} tool manages resident server processes:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    35
  @{verbatim [display]
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    36
\<open>Usage: isabelle server [OPTIONS]
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    37
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    38
  Options are:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    39
    -L FILE      logging on FILE
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    40
    -c           console interaction with specified server
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    41
    -l           list servers (alternative operation)
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    42
    -n NAME      explicit server name (default: isabelle)
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    43
    -p PORT      explicit server port
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    44
    -s           assume existing server, no implicit startup
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    45
    -x           exit specified server (alternative operation)
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    46
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    47
  Manage resident Isabelle servers.\<close>}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    48
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    49
  The main operation of \<^verbatim>\<open>isabelle server\<close> is to ensure that a named server is
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    50
  running, either by finding an already running process (according to the
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    51
  central database file @{path "$ISABELLE_HOME_USER/servers.db"}) or by
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    52
  becoming itself a new server that accepts connections on a particular TCP
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    53
  socket. The server name and its address are printed as initial output line.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    54
  If another server instance is already running, the current
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    55
  \<^verbatim>\<open>isabelle server\<close> process will terminate; otherwise, it keeps running as a
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    56
  new server process until an explicit \<^verbatim>\<open>shutdown\<close> command is received.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    57
  Further details of the server socket protocol are explained in
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    58
  \secref{sec:server-protocol}.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    59
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    60
  Other server management operations are invoked via options \<^verbatim>\<open>-l\<close> and \<^verbatim>\<open>-x\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    61
  (see below).
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    62
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    63
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    64
  Option \<^verbatim>\<open>-n\<close> specifies an alternative server name: at most one process for
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    65
  each name may run, but each server instance supports multiple connections
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    66
  and logic sessions.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    67
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    68
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    69
  Option \<^verbatim>\<open>-p\<close> specifies an explicit TCP port for the server socket (which is
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    70
  always on \<^verbatim>\<open>localhost\<close>): the default is to let the operating system assign a
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    71
  free port number.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    72
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    73
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    74
  Option \<^verbatim>\<open>-s\<close> strictly assumes that the specified server process is already
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    75
  running, skipping the optional server startup phase.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    76
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    77
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    78
  Option \<^verbatim>\<open>-c\<close> connects the console in/out channels after the initial check
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    79
  for a suitable server process. Note that the @{tool client} tool
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    80
  (\secref{sec:tool-client}) provides a more convenient way to do this
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    81
  interactively, together with command-line editor support.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    82
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    83
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    84
  Option \<^verbatim>\<open>-l\<close> lists all active server processes with their connection
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    85
  details.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    86
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    87
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    88
  Option \<^verbatim>\<open>-x\<close> exits the specified server process by sending it a \<^verbatim>\<open>shutdown\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    89
  command.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    90
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    91
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    92
  Option \<^verbatim>\<open>-L\<close> specifies a log file for exceptional output of internal server
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    93
  and session operations.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    94
\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    95
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    96
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    97
subsection \<open>Client \label{sec:tool-client}\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    98
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
    99
text \<open>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   100
  The @{tool_def client} provides console interaction for Isabelle servers:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   101
  @{verbatim [display]
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   102
\<open>Usage: isabelle client [OPTIONS]
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   103
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   104
  Options are:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   105
    -n NAME      explicit server name
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   106
    -p PORT      explicit server port
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   107
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   108
  Console interaction for Isabelle server (with line-editor).\<close>}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   109
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   110
  This is a convenient wrapper to \<^verbatim>\<open>isabelle server -s -c\<close> for interactive
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   111
  experimentation, wrapped into @{setting ISABELLE_LINE_EDITOR} if available.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   112
  The server name is sufficient for identification, as the client can
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   113
  determine the connection details from the local database of active servers.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   114
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   115
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   116
  Option \<^verbatim>\<open>-n\<close> specifies an explicit server name as in @{tool server}.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   117
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   118
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   119
  Option \<^verbatim>\<open>-p\<close> specifies an explicit server port as in @{tool server}.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   120
\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   121
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   122
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   123
subsection \<open>Examples\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   124
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   125
text \<open>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   126
  Ensure that a particular server instance is running in the background:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   127
  @{verbatim [display] \<open>isabelle server -n test &\<close>}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   128
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   129
  Here the first line of output presents the connection details:\<^footnote>\<open>This
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   130
  information may be used in an independent TCP client, while the
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   131
  Isabelle/Scala tool merely needs the server name to access the database of
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   132
  servers.\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   133
  @{verbatim [display] \<open>server "test" = 127.0.0.1:4711 (password "XYZ")\<close>}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   134
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   135
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   136
  List available server processes:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   137
  @{verbatim [display] \<open>isabelle server -l\<close>}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   138
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   139
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   140
  Connect the command-line client to the above test server:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   141
  @{verbatim [display] \<open>isabelle client -n test\<close>}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   142
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   143
  Interaction now works on a line-by-line basis, with commands like \<^verbatim>\<open>help\<close> or
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   144
  \<^verbatim>\<open>echo\<close>. For example, some JSON values may be echoed like this:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   145
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   146
  @{verbatim [display]
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   147
\<open>echo 42
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   148
echo [1, 2, 3]
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   149
echo {"a": "text", "b": true, "c": 42}\<close>}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   150
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   151
  Closing the connection (via CTRL-D) leaves the server running: it is
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   152
  possible to reconnect again, and have multiple connections at the same time.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   153
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   154
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   155
  Finally, exit the named server on the command-line:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   156
  @{verbatim [display] \<open>isabelle server -n test -x\<close>}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   157
\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   158
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   159
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   160
section \<open>Protocol messages \label{sec:server-protocol}\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   161
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   162
text \<open>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   163
  The Isabelle server listens on a regular TCP socket, using a line-oriented
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   164
  protocol of structured messages: input \<^emph>\<open>commands\<close> and output \<^emph>\<open>results\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   165
  (via \<^verbatim>\<open>OK\<close> or \<^verbatim>\<open>ERROR\<close>) are strictly alternating on the toplevel, but
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   166
  commands may also return a \<^emph>\<open>task\<close> identifier to indicate an ongoing
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   167
  asynchronous process that is joined later (via \<^verbatim>\<open>FINISHED\<close> or \<^verbatim>\<open>FAILED\<close>).
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   168
  Asynchronous \<^verbatim>\<open>NOTE\<close> messages may occur at any time: they are independent of
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   169
  the main command-reply protocol.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   170
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   171
  For example, the synchronous \<^verbatim>\<open>echo\<close> command immediately returns its
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   172
  argument as \<^verbatim>\<open>OK\<close> result. In contrast, the asynchronous \<^verbatim>\<open>session_build\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   173
  command returns \<^verbatim>\<open>OK {"task":\<close>\<open>id\<close>\<^verbatim>\<open>}\<close> and continues in the background. It
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   174
  will eventually produce \<^verbatim>\<open>FINISHED {"task":\<close>\<open>id\<close>\<^verbatim>\<open>,\<close>\<open>\<dots>\<close>\<^verbatim>\<open>}\<close> or
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   175
  \<^verbatim>\<open>FAILED {"task":\<close>\<open>id\<close>\<^verbatim>\<open>,\<close>\<open>\<dots>\<close>\<^verbatim>\<open>}\<close> with the final result. Intermediately, it
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   176
  may emit asynchronous messages of the form \<^verbatim>\<open>NOTE {"task":\<close>\<open>id\<close>\<^verbatim>\<open>,\<close>\<open>\<dots>\<close>\<^verbatim>\<open>}\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   177
  to inform about its progress. Due to the explicit task identifier, the
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   178
  client can show these messages in the proper context, e.g.\ a GUI window for
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   179
  the session build job.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   180
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   181
  \medskip Subsequently, the protocol message formats are described in further
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   182
  detail.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   183
\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   184
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   185
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   186
subsection \<open>Byte messages\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   187
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   188
text \<open>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   189
  The client-server connection is a raw byte-channel for bidirectional
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   190
  communication, but the Isabelle server always works with messages of a
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   191
  particular length. Messages are written as a single chunk that is flushed
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   192
  immediately.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   193
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   194
  The message boundary is determined as follows:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   195
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   196
    \<^item> A \<^emph>\<open>short message\<close> consists of a single line: it is a sequence of
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   197
    arbitrary bytes excluding CR (13) and LF (10), and terminated by CR-LF or
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   198
    just LF.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   199
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   200
    \<^item> A \<^emph>\<open>long message\<close> starts with a single line as above, which consists
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   201
    only of decimal digits: that is interpreted as length of the subsequent
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   202
    block of arbitrary bytes. A final line-terminator may be included here,
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   203
    but is not required.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   204
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   205
  Messages in JSON format (see below) always fit on a single line, due to
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   206
  escaping of newline characters within string literals. This is convenient
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   207
  for interactive experimentation, but it can impact performance for very long
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   208
  messages. If the message byte-length is given on the preceding line, the
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   209
  server can read the message efficiently as a single block.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   210
\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   211
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   212
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   213
subsection \<open>Text messages\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   214
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   215
text \<open>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   216
  Messages are read and written as byte streams (with byte lengths), but the
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   217
  content is always interpreted as plain text in terms of the UTF-8
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   218
  encoding.\<^footnote>\<open>See also the ``UTF-8 Everywhere Manifesto''
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   219
  \<^url>\<open>http://utf8everywhere.org\<close>.\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   220
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   221
  Note that line-endings and other formatting characters are invariant wrt.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   222
  UTF-8 representation of text: thus implementations are free to determine the
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   223
  overall message structure before or after applying the text encoding.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   224
\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   225
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   226
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   227
subsection \<open>Input and output messages\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   228
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   229
text \<open>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   230
  Server input and output messages have a uniform format as follows:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   231
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   232
    \<^item> \<open>name argument\<close> such that:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   233
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   234
    \<^item> \<open>name\<close> is the longest prefix consisting of ASCII letters, digits,
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   235
    ``\<^verbatim>\<open>_\<close>'' (underscore), or ``\<^verbatim>\<open>.\<close>'' (dot),
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   236
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   237
    \<^item> the separator between \<open>name\<close> and \<open>argument\<close> is the longest possible
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   238
    sequence of ASCII blanks (it could be empty, e.g.\ when the argument
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   239
    starts with a quote or bracket),
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   240
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   241
    \<^item> \<open>argument\<close> is the rest of the message without the line terminator.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   242
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   243
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   244
  Input messages are sent from the client to the server. Here the \<open>name\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   245
  specifies a \<^emph>\<open>server command\<close>: the list of known commands may be
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   246
  retrieved via the \<^verbatim>\<open>help\<close> command.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   247
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   248
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   249
  Output messages are sent from the server to the client. Here the \<open>name\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   250
  specifies the \<^emph>\<open>server reply\<close>, which always has a specific meaning as
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   251
  follows:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   252
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   253
    \<^item> synchronous results: \<^verbatim>\<open>OK\<close> or \<^verbatim>\<open>ERROR\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   254
    \<^item> asynchronous results: \<^verbatim>\<open>FINISHED\<close> or \<^verbatim>\<open>FAILED\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   255
    \<^item> intermediate notifications: \<^verbatim>\<open>NOTE\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   256
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   257
  \<^medskip>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   258
  The \<open>argument\<close> format is uniform for both input and output messages:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   259
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   260
    \<^item> empty argument (Scala type \<^verbatim>\<open>Unit\<close>)
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   261
    \<^item> XML element in YXML notation (Scala type \<^verbatim>\<open>XML.Elem\<close>)
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   262
    \<^item> JSON value (Scala type \<^verbatim>\<open>JSON.T\<close>)
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   263
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   264
  JSON values may consist of objects (records), arrays (lists), strings,
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   265
  numbers, bools, null.\<^footnote>\<open>See also the official specification
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   266
  \<^url>\<open>https://www.json.org\<close> and unofficial explorations ``Parsing JSON is a
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   267
  Minefield'' \<^url>\<open>http://seriot.ch/parsing_json.php\<close>.\<close> Since JSON requires
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   268
  explicit quotes and backslash-escapes to represent arbitrary text, the YXML
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   269
  notation for XML trees (\secref{sec:yxml-vs-xml}) works better
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   270
  for large messages with a lot of PIDE markup.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   271
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   272
  Nonetheless, the most common commands use JSON by default: big chunks of
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   273
  text (theory sources etc.) are taken from the underlying file-system and
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   274
  results are pre-formatted for plain-text output, without PIDE markup
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   275
  information. This is a concession to simplicity: the server imitates the
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   276
  appearance of command-line tools on top of the Isabelle/PIDE infrastructure.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   277
\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   278
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   279
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   280
subsection \<open>Initial password exchange\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   281
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   282
text \<open>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   283
  Whenever a new client opens the server socket, the initial message needs to
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   284
  be its unique password. The server replies either with \<^verbatim>\<open>OK\<close> (and some
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   285
  information about the Isabelle version) or by silent disconnection of what
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   286
  is considered an illegal connection attempt.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   287
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   288
  Server passwords are created as Universally Unique Identifier (UUID) in
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   289
  Isabelle/Scala and stored in a per-user database, with restricted
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   290
  file-system access only for the current user. The Isabelle/Scala server
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   291
  implementation is careful to expose the password only on private output
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   292
  channels, and not on a process command-line (which is accessible to other
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   293
  users, e.g.\ via the \<^verbatim>\<open>ps\<close> command).
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   294
\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   295
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   296
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   297
subsection \<open>Synchronous commands\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   298
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   299
text \<open>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   300
  A \<^emph>\<open>synchronous command\<close> corresponds to regular function application in
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   301
  Isabelle/Scala, with single argument and result (regular or error). Both the
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   302
  argument and the result may consist of type \<^verbatim>\<open>Unit\<close>, \<^verbatim>\<open>XML.Elem\<close>, \<^verbatim>\<open>JSON.T\<close>.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   303
  An error result typically consists of a JSON object with error message and
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   304
  potentially further fields (this resembles exceptions in Scala).
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   305
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   306
  These are the protocol exchanges for both cases of command execution:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   307
  \begin{center}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   308
  \begin{tabular}{rl}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   309
  \<^bold>\<open>input:\<close> & \<open>command argument\<close> \\
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   310
  (a) regular \<^bold>\<open>output:\<close> & \<^verbatim>\<open>OK\<close> \<open>result\<close> \\
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   311
  (b) error \<^bold>\<open>output:\<close> & \<^verbatim>\<open>ERROR\<close> \<open>result\<close> \\
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   312
  \end{tabular}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   313
  \end{center}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   314
\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   315
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   316
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   317
subsection \<open>Asynchronous commands\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   318
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   319
text \<open>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   320
  An \<^emph>\<open>asynchronous command\<close> corresponds to an ongoing process that finishes
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   321
  or fails eventually, while emitting arbitrary notifications intermediately.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   322
  Formally, it starts as synchronous command with immediate result \<^verbatim>\<open>OK\<close> and
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   323
  the \<^verbatim>\<open>task\<close> identifier, or an immediate \<^verbatim>\<open>ERROR\<close> that indicates bad command
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   324
  syntax. For a running task, the termination is indicated later by
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   325
  \<^verbatim>\<open>FINISHED\<close> or \<^verbatim>\<open>FAILED\<close>, together with its ultimate result.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   326
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   327
  These are the protocol exchanges for various cases of command task
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   328
  execution:
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   329
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   330
  \begin{center}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   331
  \begin{tabular}{rl}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   332
  \<^bold>\<open>input:\<close> & \<open>command argument\<close> \\
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   333
  immediate \<^bold>\<open>output:\<close> & \<^verbatim>\<open>OK {"task":\<close>\<open>id\<close>\<^verbatim>\<open>}\<close> \\
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   334
  intermediate \<^bold>\<open>output:\<close> & \<^verbatim>\<open>NOTE {"task":\<close>\<open>id\<close>\<^verbatim>\<open>,\<close>\<open>\<dots>\<close>\<^verbatim>\<open>}\<close> \\
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   335
  intermediate \<^bold>\<open>output:\<close> & \<^verbatim>\<open>NOTE {"task":\<close>\<open>id\<close>\<^verbatim>\<open>,\<close>\<open>\<dots>\<close>\<^verbatim>\<open>}\<close> \\
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   336
  (a) regular \<^bold>\<open>output:\<close> & \<^verbatim>\<open>FINISHED {"task":\<close>\<open>id\<close>\<^verbatim>\<open>,\<close>\<open>\<dots>\<close>\<^verbatim>\<open>}\<close> \\
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   337
  (b) error \<^bold>\<open>output:\<close> & \<^verbatim>\<open>FAILED {"task":\<close>\<open>id\<close>\<^verbatim>\<open>,\<close>\<open>\<dots>\<close>\<^verbatim>\<open>}\<close> \\[3ex]
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   338
  \<^bold>\<open>input:\<close> & \<open>command argument\<close> \\
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   339
  immediate \<^bold>\<open>output:\<close> & \<^verbatim>\<open>ERROR\<close>~\<open>\<dots>\<close> \\
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   340
  \end{tabular}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   341
  \end{center}
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   342
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   343
  All asynchronous messages are decorated with the task identifier that was
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   344
  revealed in the immediate (synchronous) result. Thus it is possible to emit
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   345
  further asynchronous commands and dispatch the mingled stream of
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   346
  asynchronous messages properly.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   347
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   348
  The synchronous command \<^verbatim>\<open>cancel\<close>~\<open>id\<close> tells the specified task to terminate
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   349
  prematurely: usually causing a \<^verbatim>\<open>FAILED\<close> result with error message
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   350
  \<^verbatim>\<open>Interrupt\<close>, but this is not guaranteed: the cancel event may come too
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   351
  late or the task may just ignore it.
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   352
\<close>
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   353
465f43a9f780 documentation for the Isabelle server;
wenzelm
parents:
diff changeset
   354
end