Module ce_poll

Polling design pattern.

Description

Polling design pattern.

Although it is preferable to see things happening in Erlang in terms of real-time events or messages, sometimes it is unavoidable to poll (periodically check a resource.)

This module provides a compromise by making polling look like plain Erlang messages, even though it is not technically in real-time.

Function Index

loop/4Drives the polling.
start/2Starts a polling service.
test/0Test function.

Function Details

loop/4

loop(Function::'fun'(), Interval::integer(), Parent::pid(), Value::term()) -> never_returns()

Drives the polling. This function is spawned by start/2 and should not be used by external callers.

start/2

start(Function::'fun'(), Interval::integer()) -> {ok, pid()} | {error, Reason}

Starts a polling service. Function (a fun/0) will be called immediately, and every Interval milliseconds thereafter. Each time the return value of it has changed from the previous value, a message {ce_poll, pid(), NewValue} will be sent to the process that called start/2.

test/0

test() -> never_returns()

Test function. Monitors the current directory and displays file additions and removals no more than a second later than they happen.


Generated by EDoc, Feb 18 2008, 06:48:00.