Skip to content
A Library that make the write from synchronous to asynchronous.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
example 1. solve the memory type rotate bug; 2. update makefile support __PER… May 25, 2015
include Update logging.h Jun 23, 2017
src fix bug:delete consume Nov 27, 2015
test first commit Sep 22, 2014
tool add support file type Nov 6, 2014
.gitignore add to gitignore Nov 6, 2014
LICENSE Initial commit Sep 22, 2014
Makefile fix kBlockSize May 29, 2015 revise README Mar 30, 2017
changelog first commit Sep 22, 2014


A library that makes the write from synchronous to asynchronous.

It is thread-safe and easily used.


The Mario library helps when you want to quickly return from time-consuming operators and leave the work to the background.

With Mario, you just need the implement your own consume message function and let Mario create background threads to do other stuff.

Two engine types

  • memory

This type will leave the cache buffer in memory. The advantage is the Insert speed is faster. But when your application shutdown before you have consume the data in the buffer, The data will lost.

  • file

Thie type will make a write2file in the local log path. When you put message, you will write the data in the write2file. The write is append operator, so it is also very fast. The application don't initiativly flush the data to disk, it flush according to the operator system.

If there is still some data havn't been consumed after shutdown you application, it doesn't matter. it will leave a menifest file in the log path, after you restart you application. it will first get the menifest file, and get the offset. Then it consume the data from the offset


make ENGINE=memory

then you will get a output path in this path, it include the lib and the include file.

You also can see how to used in the example path


#include "mario.h"
#include "consumer.h"
#include "mutexlock.h"
#include "port.h"

 * @brief The handler inherit from the Consumer::Handler
 * The processMsg is pure virtual function, so you need implementation your own
 * version
class FileHandler : public mario::Consumer::Handler
        FileHandler() {};
        virtual void processMsg(const std::string &item) {
            log_info("consume data %s",;

int main()
    mario::Status s;
    FileHandler *fh = new FileHandler();
     * @brief
     * @param 1 is the thread number
     * @param fh is the handler that you implement. It tell the mario how
     * to consume the data
     * @return
    mario::Mario *m = new mario::Mario(1, fh);

    std::string item = "Put data in mario";
    s = m->Put(item);
    if (!s.ok()) {
        log_err("Put error");

    delete m;
    delete fh;
    return 0;

You can’t perform that action at this time.