A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://faasm.readthedocs.io/en/latest/source/cpp.html below:

Website Navigation


C++ support — Faasm documentation

C++ support

All C++ work takes place in the cpp container, i.e.:

From here you can compile, upload and invoke different functions defined in the Faasm C++ repo, or add your own.

If you want to upload C/C++ functions from other repos, you can look at the Faasm HTTP API.

Compiling a C++ function

A simple hello world function is demo/hello which just returns a hello message.

From the Faasm CLI, you can compile, upload and invoke the hello.cpp function with:

inv func.compile demo hello
inv func.upload demo hello
inv func.invoke demo hello

You should then see the response Hello faasm!.

Updating a function

You can edit the message in the hello.cpp file, then update and invoke again with:

# Recompile and upload
inv func.compile demo hello
inv func.upload demo hello

# Flush - this is important to remove any cached versions of your function
inv func.flush

# Invoke again
inv func.invoke demo hello
Writing functions

Faasm aims to be uninvasive, allowing code to run natively and in a serverless context. This means the simplest Faasm function looks like:

int main(int argc, char* argv[]) {
    // Do something

    return 0;
}
C++ API

Faasm provides a simple C++ wrapper library around the Faasm host interface. Some of the methods in this wrapper are:

They are found in the cpp repo.

Chaining

“Chaining” is when one function makes a call to another function (which must be owned by the same user). There are two supported methods of chaining, one for invoking totally separate Faasm functions, the other for automatically parallelising functions in the same piece of code (useful for porting legacy applications).

Chaining a function

Multiple functions can be defined in the same file, invoke each other and await results.

Functions can either be chained by passing another function’s name, or by passing a pointer to a function in the same file.

Examples:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4