• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

14 Deploying applications
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Deploying applications
        • Deployment options
        • Understanding saved states
        • State initialization
        • Using program resources
        • Debugging and updating deployed systems
        • Protecting your code
        • Finding Application files
    • Packages

14.3 State initialization

The initialization/1 and initialization/2 directive may be used to register goals to be executed at various points in the life cycle of an executable. Alternatively, one may consider lazy initialization which typically follows the pattern below. Single threaded code can avoid using with_mutex/2.

:- dynamic x_done/0.
:- volatile x_done/0.

x(X) :-
    x_done,
    !,
    use_x(X).
x(X) :-
    with_mutex(x, create_x),
    use_x(X).

create_x :-
    x_done,
    !.
create_x :-
    <create x>
    asserta(x_done).

ClioPatria (version V3.1.1-51-ga0b30a5)