The moira Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The moira Reference Manual

This is the moira Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Tue Feb 20 09:05:41 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Μοῖρα

Moira is a simple (but not quite trivial) library for monitoring and, if necessary, restarting long-running threads. In principle, it is like an in-Lisp process supervisor.

To start the monitor, you call start-monitor:

(moira:start-monitor)

Once the monitor is started, you can spawn new threads:

(moira:spawn "Background worker"
  ...))

Which is syntactic sugar for

(moira:spawn-thread
 (lambda () ...)
 :name "Background worker")

If the thread created by spawn-thread should crash, or otherwise exit abnormally, Moira will step in and restart the thread.

You can stop monitoring with stop-monitor

(moira:stop-monitor)

Although this will not affect the spawned threads.

On Linux only, Moira also tracks the thread ID (value of gettid) of the Lisp threads it launches. This can be useful for tracking the resource usage of individual thr


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 moira

Author

Paul M. Rodriguez <pmr@ruricolist.com>

License

MIT

Description

Monitor and restart background threads.

Dependencies
Source

moira.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 moira.asd

Location

moira.asd

Systems

moira (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 moira/package.lisp

Parent

moira (system)

Location

package.lisp

Packages

moira


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.3 moira/types.lisp

Dependency

package.lisp (file)

Parent

moira (system)

Location

types.lisp

Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.4 moira/thread-ids.lisp

Dependency

package.lisp (file)

Parent

moira (system)

Location

thread-ids.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.5 moira/moira.lisp

Dependencies
Parent

moira (system)

Location

moira.lisp

Exported Definitions

list-monitored-threads (function)

Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.6 moira/monitor.lisp

Dependencies
Parent

moira (system)

Location

monitor.lisp

Exported Definitions
Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

3.1.7 moira/spawn.lisp

Dependencies
Parent

moira (system)

Location

spawn.lisp

Exported Definitions
Internal Definitions

make-thread-and-wait (function)


Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 moira

Source

package.lisp (file)

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Macros

Macro: spawn &body BODY

Like (spawn-thread (lambda () ...)).
If the first form in BODY is a string, that string is used as the name of the thread.

Package

moira

Source

spawn.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: list-monitored-threads ()
Package

moira

Source

moira.lisp (file)

Function: make-thread-saving-id THUNK &rest ARGS

Like ‘bt:make-thread’, but save the id of the resulting thread so it can be retrieved later with ‘moira:thread-id’.

Using ‘moira:make-thread-saving-id’ lets you start a thread that is not monitored, but does have its ID tracked.

Package

moira

Source

spawn.lisp (file)

Function: save-current-thread-id ()
Package

moira

Source

thread-ids.lisp (file)

Function: spawn-thread THUNK &key NAME

Run THUNK as a thread, automatically respawning if the thread exits abnormally.

Package

moira

Source

spawn.lisp (file)

Function: start-monitor ()
Package

moira

Source

monitor.lisp (file)

Function: stop-monitor ()
Package

moira

Source

monitor.lisp (file)

Function: thread-id THREAD
Package

moira

Source

thread-ids.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *monitor*
Package

moira

Source

monitor.lisp (file)

Special Variable: *monitored-threads*
Package

moira

Source

moira.lisp (file)

Special Variable: *thread-ids*
Package

moira

Source

thread-ids.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Symbol macros

Symbol Macro: monitor-flag
Package

moira

Source

monitor.lisp (file)

Expansion

moira::*storage-for-deflex-var-monitor-flag*


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Functions

Function: clear-monitored-threads ()
Package

moira

Source

moira.lisp (file)

Function: id-thread ID
Package

moira

Source

thread-ids.lisp (file)

Function: make-thread-and-wait THUNK &rest ARGS

Like ‘make-thread-saving-id’, but wait to return until the thread is actually running.

Package

moira

Source

spawn.lisp (file)

Function: monitor-loop ()
Package

moira

Source

monitor.lisp (file)

Function: thread-alive-p X
Package

moira

Source

types.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.4 Generic functions

Generic Function: ensure-alive SELF
Package

moira

Methods
Method: ensure-alive (SELF monitored-thread)
Source

moira.lisp (file)

Generic Function: monitored-thread.donep OBJECT
Package

moira

Methods
Method: monitored-thread.donep (MONITORED-THREAD monitored-thread)

automatically generated reader method

Source

moira.lisp (file)

Generic Function: monitored-thread.name OBJECT
Package

moira

Methods
Method: monitored-thread.name (MONITORED-THREAD monitored-thread)

automatically generated reader method

Source

moira.lisp (file)

Generic Function: monitored-thread.thread OBJECT
Package

moira

Methods
Method: monitored-thread.thread (MONITORED-THREAD monitored-thread)

automatically generated reader method

Source

moira.lisp (file)

Generic Function: monitored-thread.thunk OBJECT
Package

moira

Methods
Method: monitored-thread.thunk (MONITORED-THREAD monitored-thread)

automatically generated reader method

Source

moira.lisp (file)

Generic Function: start SELF
Package

moira

Methods
Method: start (SELF monitored-thread)
Source

moira.lisp (file)

Generic Function: stop SELF
Package

moira

Methods
Method: stop (SELF monitored-thread)
Source

moira.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.5 Classes

Class: monitored-thread ()
Package

moira

Source

moira.lisp (file)

Direct superclasses

synchronized (class)

Direct methods
Direct slots
Slot: thread
Type

moira::a-thread

Readers

monitored-thread.thread (generic function)

Slot: done
Type

boolean

Readers

monitored-thread.donep (generic function)

Slot: thunk
Type

function

Initargs

:thunk

Readers

monitored-thread.thunk (generic function)

Slot: name
Type

string

Initargs

:name

Readers

monitored-thread.name (generic function)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.6 Types

Type: a-thread ()
Package

moira

Source

types.lisp (file)

Type: dead-thread ()
Package

moira

Source

types.lisp (file)

Type: live-thread ()
Package

moira

Source

types.lisp (file)

Type: no-thread ()
Package

moira

Source

types.lisp (file)

Type: thread ()
Package

moira

Source

types.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   M  
Index Entry  Section

F
File, Lisp, moira.asd: The moira<dot>asd file
File, Lisp, moira/moira.lisp: The moira/moira<dot>lisp file
File, Lisp, moira/monitor.lisp: The moira/monitor<dot>lisp file
File, Lisp, moira/package.lisp: The moira/package<dot>lisp file
File, Lisp, moira/spawn.lisp: The moira/spawn<dot>lisp file
File, Lisp, moira/thread-ids.lisp: The moira/thread-ids<dot>lisp file
File, Lisp, moira/types.lisp: The moira/types<dot>lisp file

L
Lisp File, moira.asd: The moira<dot>asd file
Lisp File, moira/moira.lisp: The moira/moira<dot>lisp file
Lisp File, moira/monitor.lisp: The moira/monitor<dot>lisp file
Lisp File, moira/package.lisp: The moira/package<dot>lisp file
Lisp File, moira/spawn.lisp: The moira/spawn<dot>lisp file
Lisp File, moira/thread-ids.lisp: The moira/thread-ids<dot>lisp file
Lisp File, moira/types.lisp: The moira/types<dot>lisp file

M
moira.asd: The moira<dot>asd file
moira/moira.lisp: The moira/moira<dot>lisp file
moira/monitor.lisp: The moira/monitor<dot>lisp file
moira/package.lisp: The moira/package<dot>lisp file
moira/spawn.lisp: The moira/spawn<dot>lisp file
moira/thread-ids.lisp: The moira/thread-ids<dot>lisp file
moira/types.lisp: The moira/types<dot>lisp file

Jump to:   F   L   M  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   C   E   F   G   I   L   M   S   T  
Index Entry  Section

C
clear-monitored-threads: Internal functions

E
ensure-alive: Internal generic functions
ensure-alive: Internal generic functions

F
Function, clear-monitored-threads: Internal functions
Function, id-thread: Internal functions
Function, list-monitored-threads: Exported functions
Function, make-thread-and-wait: Internal functions
Function, make-thread-saving-id: Exported functions
Function, monitor-loop: Internal functions
Function, save-current-thread-id: Exported functions
Function, spawn-thread: Exported functions
Function, start-monitor: Exported functions
Function, stop-monitor: Exported functions
Function, thread-alive-p: Internal functions
Function, thread-id: Exported functions

G
Generic Function, ensure-alive: Internal generic functions
Generic Function, monitored-thread.donep: Internal generic functions
Generic Function, monitored-thread.name: Internal generic functions
Generic Function, monitored-thread.thread: Internal generic functions
Generic Function, monitored-thread.thunk: Internal generic functions
Generic Function, start: Internal generic functions
Generic Function, stop: Internal generic functions

I
id-thread: Internal functions

L
list-monitored-threads: Exported functions

M
Macro, spawn: Exported macros
make-thread-and-wait: Internal functions
make-thread-saving-id: Exported functions
Method, ensure-alive: Internal generic functions
Method, monitored-thread.donep: Internal generic functions
Method, monitored-thread.name: Internal generic functions
Method, monitored-thread.thread: Internal generic functions
Method, monitored-thread.thunk: Internal generic functions
Method, start: Internal generic functions
Method, stop: Internal generic functions
monitor-loop: Internal functions
monitored-thread.donep: Internal generic functions
monitored-thread.donep: Internal generic functions
monitored-thread.name: Internal generic functions
monitored-thread.name: Internal generic functions
monitored-thread.thread: Internal generic functions
monitored-thread.thread: Internal generic functions
monitored-thread.thunk: Internal generic functions
monitored-thread.thunk: Internal generic functions

S
save-current-thread-id: Exported functions
spawn: Exported macros
spawn-thread: Exported functions
start: Internal generic functions
start: Internal generic functions
start-monitor: Exported functions
stop: Internal generic functions
stop: Internal generic functions
stop-monitor: Exported functions

T
thread-alive-p: Internal functions
thread-id: Exported functions

Jump to:   C   E   F   G   I   L   M   S   T  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
D   M   N   S   T  
Index Entry  Section

*
*monitor*: Internal special variables
*monitored-threads*: Internal special variables
*thread-ids*: Internal special variables

D
done: Internal classes

M
monitor-flag: Internal symbol macros

N
name: Internal classes

S
Slot, done: Internal classes
Slot, name: Internal classes
Slot, thread: Internal classes
Slot, thunk: Internal classes
Special Variable, *monitor*: Internal special variables
Special Variable, *monitored-threads*: Internal special variables
Special Variable, *thread-ids*: Internal special variables
Symbol Macro, monitor-flag: Internal symbol macros

T
thread: Internal classes
thunk: Internal classes

Jump to:   *  
D   M   N   S   T  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   A   C   D   L   M   N   P   S   T  
Index Entry  Section

A
a-thread: Internal types

C
Class, monitored-thread: Internal classes

D
dead-thread: Internal types

L
live-thread: Internal types

M
moira: The moira system
moira: The moira package
monitored-thread: Internal classes

N
no-thread: Internal types

P
Package, moira: The moira package

S
System, moira: The moira system

T
thread: Internal types
Type, a-thread: Internal types
Type, dead-thread: Internal types
Type, live-thread: Internal types
Type, no-thread: Internal types
Type, thread: Internal types

Jump to:   A   C   D   L   M   N   P   S   T