Skip to content

Latest commit

 

History

History
30 lines (21 loc) · 716 Bytes

proto_faaslets.md

File metadata and controls

30 lines (21 loc) · 716 Bytes

Proto-Faaslets

Proto-Faaslets are a way to reduce the initialisation time of functions. They are a chunk of code that executes once and is then used to spawn all subsequent function invocations. The complete state of the function after Proto-Faaslet execution is duplicated for all subsequent function invocations.

The Proto-Faaslet should be idempotent as it may be run more than once.

Proto-function code is marked up with the FAASM_ZYGOTE macro:

#include "faasm/faasm.h"

int myGlobal;

FAASM_ZYGOTE() {
    // Run once
    myGlobal = 5;

    return 0;
}

FAASM_MAIN_FUNC() {
    // Context available to all subsequent function calls
    printf("My global = %i\n", myGlobal);

    return 0;
}