overview - OkCupid/sfslite GitHub Wiki
sfslite Source Tree Overview
sfslite has many useful components for simplifying the development of event-driven network programs in C++.
sfslite and the SFS libraries are also known as libasync, which is somewhat of a misnomer, since the sfslite/SFS suite contain libasync in addition to other libraries.
- Main event loop (
amainandacheck) and mechanisms for registering callbacks to handle:- file descriptor read/write-ability using
fdcb, - periodic actions using
delaycb, - unix signals using
sigcb.
- file descriptor read/write-ability using
- Reference counted data structures (
refcnt.h) - Closure-like syntax for generating callbacks and maintaining state across actions (
wrapincallback.h) - Reference counted string objects (
str.h): immutable strings, string buffers, mutable strings and mutable strings that are explicitly wiped after use. suioin C++, a wrapper to simplify usingiovecto efficiently buffering input and output.aiosfor writing line-oriented network servers/clients.- Data structures:
- generic linked list logic (
list.h) - generic hash table logic:
ihashfor when you provide struct that knows it is in a hash table,qhashfor generic structs into hash tables,bhashfor when you just want to keep track of whether or not a key is present (ihash.handqhash.h). A short tutorial on qhash is available here. - dynamic arrays (
vec.h) - red black trees (
itree.h)
- generic linked list logic (
- Functions/classes for common operations:
- Allocating sockets (
inetsocket,make_async,unixsocket) - asynchronous DNS lookups.
- asynchronous TCP connections (
tcpconnect) - Daemonizing servers
- Logging, error output and traces (
err.h) - Parsing configuration files (
parseopt.h) - Regular expressions (via the pcre library)
- Allocating sockets (
Sfslite makes extensive use of C++ templates to provide flexibility without sacrificing type safety. sfslite does not use floating point operations. sfslite is designed to integrate well with the dmalloc debugging malloc library.
A basic tutorial on using the SFS/sfslite libraries is available from PDOS.
If you have any tips for using libasync, please contribute them!