Web服务器插件
Felix web服务器由一个程序组成 dflx_web 它加载了几个插件。有一个版本 flx_web 它由完全相同的程序组成,但是带有预先链接的插件。以下是预链接代码:
class WebserverPluginSymbols
{
// We have to do this dummy requirements because static
// linking removes
requires package "re2";
requires package "faio";
requires package "flx_arun";
open Dynlink;
// Now add all the symbols.
proc addsymbols ()
{
static-link-plugin
fdoc2html,
flx2html,
fpc2html,
py2html,
ocaml2html,
cpp2html,
fdoc_scanner,
fdoc_slideshow,
fdoc_heading,
fdoc_fileseq,
fdoc_paragraph,
fdoc_button,
fdoc_frame,
fdoc_edit,
toc_menu
;
// webserver
static-link-symbol dflx_web_create_thread_frame in plugin dflx_web;
static-link-symbol dflx_web_flx_start in plugin dflx_web;
}
}
// Add the symbols
WebserverPluginSymbols::addsymbols;
// Now invoke the webserver!
println$ "Running webserver";
val linstance = Dynlink::prepare_lib("dflx_web");
println$ "Webserver prepared";
var init: cont = Dynlink::get_init linstance;
Fibres::chain init;
在这种情况下,程序在初始化后连续运行,因此我们得到主线延续 init 从插件实例 linstance 把它拴起来。