3. OVERVIEW
• A Library that make the write from synchronous
to asynchronous.
• It is thread safe and easily used.
4. EXAMPLE
/**
*
@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
{
public:
FileHandler()
{};
virtual
void
processMsg(const
std::string
&item)
{
log_info("consume
data
%s",
item.data());
}
};
5. EXAMPLE
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");
exit(-‐1);
}
delete
m;
delete
fh;
return
0;
}
7. IMPLEMENT
• The base idea of the Mario is that if you have operators
that cost lots of time. But you want quickly return from
the operator, and leave the work to the background.
• So mario library can easily solve your problem. You just
need the implement your own consume message
function. Then mario will create background thread do
the other things.
8. ENGINE
• Memory
• make ENGINE=memory
• File
• make ENGINE=file
• write2file
• manifest
9. USAGE
• make ENGINE=memory
• ls output
• include/ lib/