actor

package
v0.0.0-...-126e8e4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2019 License: Apache-2.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

type Actor interface {
	// Receive is called when Actor receives a new Message.
	// Returns a new Actor state and/or error.
	Receive(message Message) (Actor, error)
}

Actor is an entity that processes messages, sends messages to other actors and stores some state.

type Constructor

type Constructor func(system System, pid Pid) (state Actor, limit int)

Constructor is a procedure that creates a new Actor. It is called when Actor is created, before receiving any Messages. `state` sets the initial actor state. If `limit` is > 0 it sets the maximum size of the mailbox (only for regular, not stashed, not priority messages).

type Message

type Message interface{}

Message represents a message sent between actors.

type Pid

type Pid uint64

Pid is an unique ID of the Actor.

type System

type System interface {
	// Spawn creates a new Actor and returns it's Pid.
	Spawn(constructor Constructor) Pid

	// Send sends a Message to the Actor with a given Pid. InvalidPid is
	// returned if actor with a given Pid doesn't exist or was terminated.
	// MailboxFull is returned if acrtor's mailbox is full.
	Send(pid Pid, message Message) error

	// SendPriority sends a priority Message to the Actor with a given Pid.
	// Priority messages are processed before any other messages. InvalidPid is
	// returned if actor with a given Pid doesn't exist or was terminated.
	SendPriority(pid Pid, message Message) error

	// AwaitTermination returns when all spawned Actors terminate.
	AwaitTermination()
}

System is a class responsible for creating, scheduling and otherwise controlling actors.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL