Lev - Lightweight C++ wrapper for LibEvent 2 API

Overview

lev

Lightweight C++ wrapper for LibEvent 2 API

Build Status

LibEvent is a great library. It uses a C interface which is well designed but has a learning curve. This library, lev, is a very simple API in C++ that encapsulates commonly used functionality. It tries to stay close to the libevent API concepts except when there is confusion. It simplifies life-times of objects. The callback function signatures remain identical--but lev objects can be constructed within the callback functions.

      EvHttpRequest evreq(req);

lev is actually just a couple of header file, lev.h, and levhttp.h (if you need a httpserver). Just include it in your application and start using all the classes--no need to build or install:

class IpAddr;
class EvBaseLoop;
class EvEvent;
class EvKeyValues;
class EvBuffer;
class EvBufferEvent;
class EvConnListener;
class EvHttpUri;
class EvHttpRequest;
class EvHttpServer;

Code: An HTTP server using lev. Look at the example section for more.

  #include "lev.h"
  #include "levhttp.h"
  using namespace lev;

  static
  void onHttpHello(struct evhttp_request* req, void* arg)
  {
      EvHttpRequest evreq(req);
      evreq.output().printf("<..>Hello World!<..>");
      evreq.sendReply(200, "OK");
  }

  int main(int argc, char** argv)
  {
      EvBaseLoop base;
      EvHttpServer http(base);

      http.addRoute("/hello", onHttpHello);
      http.bind("127.0.0.1", 8080);

      base.loop();

      return 0;
  }
You might also like...
Like libevent and libuv, libhv provides event-loop with non-blocking IO and timer, but simpler api and richer protocols.
Like libevent and libuv, libhv provides event-loop with non-blocking IO and timer, but simpler api and richer protocols.

中文版 Intro Like libevent, libev, and libuv, libhv provides event-loop with non-blocking IO and timer, but simpler api and richer protocols. Features cr

Like libevent and libuv, libhv provides event-loop with non-blocking IO and timer, but simpler api and richer protocols.
Like libevent and libuv, libhv provides event-loop with non-blocking IO and timer, but simpler api and richer protocols.

中文版 Intro Like libevent, libev, and libuv, libhv provides event-loop with non-blocking IO and timer, but simpler api and richer protocols. Features cr

KBMS is a C++11 high performance network framework based on libevent.

KBMS is a C++11 high performance network framework based on libevent. It is light and easy to deploy. At present, it mainly supports HTTP protocol.

Native C++ coroutines for libevent

libevent-async libevent-async is a C++ wrapper around the libevent API. It wraps commonly-used objects in classes and provides coroutine support for m

Full-featured high-performance event loop loosely modelled after libevent

libev is a high-performance event loop/event model with lots of features. (see benchmark at http://libev.schmorp.de/bench.html) ABOUT Homepage:

The goal of arrowvctrs is to wrap the Arrow Data C API and Arrow Stream C API to provide lightweight Arrow support for R packages

The goal of arrowvctrs is to wrap the Arrow Data C API and Arrow Stream C API to provide lightweight Arrow support for R packages to consume and produce streams of data in Arrow format. Right now it’s just a fun way for me to learn about Arrow!

lightweight, compile-time and rust-like wrapper around the primitive numerical c++ data types

prim_wrapper header-only, fast, compile-time, rust-like wrapper around the primitive numerical c++ data types dependencies gcem - provides math functi

Lightweight C++ wrapper for SQLite

NLDatabase Lightweight C++ wrapper for SQLite. Requirements C++11 compiler SQLite 3 Usage Let's open a database file and read some rows: #include "NLD

Lightweight OpenCL-Wrapper to greatly simplify OpenCL software development with C++ while keeping functionality and performance

OpenCL-Wrapper OpenCL is the most powerful programming language ever created. Yet the OpenCL C++ bindings are very cumbersome and the code overhead pr

Sol3 (sol2 v3.0) - a C++ - Lua API wrapper with advanced features and top notch performance - is here, and it's great! Documentation:

sol2 sol2 is a C++ library binding to Lua. It currently supports all Lua versions 5.1+ (LuaJIT 2.0+ and MoonJIT included). sol2 aims to be easy to use

Wrapper library for the BSD sockets API with a nicer C99 interface

A wrapper library for the BSD sockets API. Why? This library trades the series of getaddrinfo, socket, connect, bind, listen, etc. functions and their

Implement yolov5 with Tensorrt C++ api, and integrate batchedNMSPlugin. A Python wrapper is also provided.
Implement yolov5 with Tensorrt C++ api, and integrate batchedNMSPlugin. A Python wrapper is also provided.

yolov5 Original codes from tensorrtx. I modified the yololayer and integrated batchedNMSPlugin. A yolov5s.wts is provided for fast demo. How to genera

cudnn_frontend provides a c++ wrapper for the cudnn backend API and samples on how to use it

cuDNN Frontend API Introduction The cuDNN Frontend API is a C++ header-only library that demonstrates how to use the cuDNN C backend API. The cuDNN C

SQLite3++ - C++ wrapper of SQLite3 API

ANNOUNCEMENTS Use files in headeronly_src directory. The files in src are exactly same but in the form of h/cpp files, which you need to compile and l

A simple API wrapper that generates images & facts of any animal

animality.h A simple API wrapper that generates images & facts of any animal Required dependencies: libcurl for sending HTTPS requests. pthreads for t

Header only wrapper around Hex-Rays API in C++20.

HexSuite HexSuite is a header only wrapper around Hex-Rays API in C++20 designed to simplify the use of Hex-Rays and IDA APIs by modern C++ features.

Fiber - A header only cross platform wrapper of fiber API.

Fiber Header only cross platform wrapper of fiber API A fiber is a particularly lightweight thread of execution. Which is useful for implementing coro

CSteamworks is a C ABI Wrapper for Valve's Steamworks API

CSteamworks Note: This project is deprecated as Valve now prodives a C ABI wrapper built into steam_api.dll. CSteamworks is a C ABI Wrapper for Valve'

Direct3D wrapper for Sega's Kamui API

KAMUI Direct! Circa 1997 Sega was developing the KAMUI graphics API used for their newest console, the Dreamcast. There were no devkits yet, so the pr

Comments
  • Biicode support

    Biicode support

    Hi!

    My name is Luis Martinez and I write you from biicode a small start-up that’s developing a C and C++ dependency manager; just like Maven and Maven Central for Java. Our tool aims to allow our users to set-up a project with just #includes.

    We took a look to lev library and realized it is pretty amazing. I have forked your repository to support biicode and uploaded a biicode block to http://www.biicode.com/lasote/lev

    How can biicode be useful for you?

    • We already have libevent and openssl uploaded on biicode, so it's not necessary to take care about having the dependency in your project, downloading, installing or building... just #include it.
    • People that like your library can easy include it, so, more people can use your code.

    Here is an example

    Install biicode. https://www.biicode.com/downloads Create new project folder and a block folder:

    $ bii init lev_project
    $ cd lev_project
    $ bii new some_user/lev_example
    

    Create a "main.cpp" file in "blocks/some_user/lev_example" folder and directly #include your library headers with the block namespace. You can use any of your examples:

    #include "lasote/lev/include/lev.h" #include "lasote/lev/include/levhttp.h"

    (Note:If you think it's annoying for users to change their includes do not worry: there is an easy way to do a mapping inside biicode.conf file, so you can keep the includes like lev.h and levhttp.h)

    Execute "bii find" and biicode will download the required files (libevent included!):

    $ bii find
    

    Compile the example:

    $ bii cpp:build
    

    The uploaded block is on lasote/lev, but we will glad if you want to upload the library to your biicode's user. So your users could maybe type #include "yasser/lev/include/lev.h" and reuse your code!

    If you would to do that, just rename block folder from "lasote" to your user, ex "yasser", and edit biicode.conf file and change the [parent] block (track from biicode remote) to yasser/lev: -1

    This way biicode will publish a new block in your user workspace:

    $ bii publish --tag STABLE If you want to know more about biicode or need help just write me! [email protected]

    Thanks!

    opened by lasote 1
  • README with biicode badge

    README with biicode badge

    Thanks for merge!

    I put a badge to help people to know that your library can be used with biicode. If you want to try biicode I could transfer lasote/lev library to your biicode user.

    Thanks for your lib!

    opened by lasote 0
  • Syntax highlight the README code examples

    Syntax highlight the README code examples

    Thanks for making this great library! This PR adds syntax highlighting to the code examples in the README, which makes the code examples more readable. You can see how this is rendered on GitHub here: https://github.com/eklitzke/lev/tree/hilite

    opened by eklitzke 0
Owner
Yasser Asmi
Programmer at Microsoft
Yasser Asmi
Fiber - A header only cross platform wrapper of fiber API.

Fiber Header only cross platform wrapper of fiber API A fiber is a particularly lightweight thread of execution. Which is useful for implementing coro

Tony Wang 41 Jul 31, 2022
A small C OpenCL wrapper

oclkit, plain and stupid OpenCL helper oclkit is a small set of C functions, to avoid writing the same OpenCL boiler plate over and over again, yet ke

Matthias Vogelgesang 15 Jul 22, 2022
Jobxx - Lightweight C++ task system

jobxx License Copyright (c) 2017 Sean Middleditch [email protected] This is free and unencumbered software released into the public domain. A

Sean Middleditch 77 May 28, 2022
ThreadPool - Lightweight, Generic, Pure C++11 ThreadPool

ThreadPool Lightweight, Generic, Pure C++11 ThreadPool Rational I needed a Thread Pool for something I was writing, and I didn't see any that I liked.

Neil 266 Jan 8, 2023
Thin C++-flavored wrappers for the CUDA Runtime API

cuda-api-wrappers: Thin C++-flavored wrappers for the CUDA runtime API Branch Build Status: Master | Development: nVIDIA's Runtime API for CUDA is int

Eyal Rozenberg 548 Dec 28, 2022
checkedthreads: no race condition goes unnoticed! Simple API, automatic load balancing, Valgrind-based checking

checkedthreads checkedthreads is a fork-join parallelism framework for C and C++ providing: Automated race detection using debugging schedulers and Va

Yossi Kreinin 279 Nov 4, 2022
Simple and fast C library implementing a thread-safe API to manage hash-tables, linked lists, lock-free ring buffers and queues

libhl C library implementing a set of APIs to efficiently manage some basic data structures such as : hashtables, linked lists, queues, trees, ringbuf

Andrea Guzzo 392 Dec 3, 2022
OOX: Out-of-Order Executor library. Yet another approach to efficient and scalable tasking API and task scheduling.

OOX Out-of-Order Executor library. Yet another approach to efficient and scalable tasking API and task scheduling. Try it Requirements: Install cmake,

Intel Corporation 18 Oct 25, 2022
Lucy job system - Fiber-based job system with extremely simple API

Lucy Job System This is outdated compared to Lumix Engine. Use that instead. Fiber-based job system with extremely simple API. It's a standalone versi

Mikulas Florek 80 Dec 21, 2022
Fast, generalized, implementation of the Chase-Lev lock-free work-stealing deque for C++17

riften::Deque A bleeding-edge lock-free, single-producer multi-consumer, Chase-Lev work stealing deque as presented in the paper "Dynamic Circular Wor

Conor Williams 120 Dec 22, 2022