# simple-cpp-middleware **Repository Path**: majz0908/simple-cpp-middleware ## Basic Information - **Project Name**: simple-cpp-middleware - **Description**: No description available - **Primary Language**: C++ - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 1 - **Created**: 2021-06-12 - **Last Updated**: 2021-06-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # simple c++ middleware As it's name, it's a light simple middleware library for c++ developers without any third library, and only for Linux and MacOS based raw OS kernal clang API and asm. * Memory pool * Lock based AQS * Blocking queue * Thread pool * High performance share memory management(todo). ## Backgroud When we want to develop a small system, properly need depend on some third big library even if we only use a litle part of it. ## Building and test Clean the old target. Use make clean command: ``` [root@localhost simple-cpp-middleware]# make clean cleaned up. ``` How to build it. Execute Makefile make command to build the library as: ``` [root@localhost simple-cpp-middleware]# make start build... build success! ``` Test it use the make test command like: ``` [root@localhost simple-cpp-middleware]# make test start build the test source code... build test code success! start execute test... test proccess is ready, start test>>> ... ... test result output ... ... test is over, press [Enter] to finish. test finished! ``` And also you can use group command once like make clean all test. ``` [root@localhost simple-cpp-middleware]# make clean all test cleaned up. start build... build success! start build the test source code... build test code success! start execute test... test proccess is ready, start test>>> ... ... test result output ... ... test is over, press [Enter] to finish. test finished! ``` ## API document ### Memory pool include the memory_pool.h ``` file: demo.c #include "memory_pool.h" int main(int argc, char const *argv[]) { //At first alloc 10M space from system to init memory pool mem_init(1024 * 1024 * 10); //Malloc some memory from memory pool void * buffer = mem_malloc(1024); //Use the memory do something const char* data = "some data..."; memcpy(buffer, data, strlen(data)); //At last release the memory mem_free(buffer); return 0; } ``` ### Lock and thread usage ``` #include "ReentrantLock.h" #include "Thread.h" int main(int argc, char const *argv[]) { //At first init a Lock instance. ReentrantLock lock; //Ant start a thread return 0; } ```