Pirx un[blog]ged

Mike is reading four blogs. This is none of them.

Introduction into CYY library

The C++ library CYY is an effort to provide a clean library useful in multi-threaded environments like TCP/IP servers, application servers or clients with heavy load. Especially the active object pattern is well supported accompanied by simple mechanisms to prevent dead locks and race conditions (lock hierarchies). It has a predecessor that is much in use but limited as closed source project. CYY is a complete rewrite as an open source project under the BOOST license.

The CYY library is still under heavy development but some parts are already useful (and in use). Next step will be the release of a stable 0.1 version. For the the curious I will briefly explain the main parts in a most non-technical way. Main focus is to give an architectural overview:

CORE: The core library is simply the core. Main objective is to provide an extensible mechanism to convert every C++ data type into a generalized object and visa versa. There is a comprehensive set of intrinsic data types that can be expanded if required. It's a little bit like boost:any on steroids. The surprising result is a C++ language with features of a scripting language:

const auto lhs = cyy::factory(2);
const auto rhs = cyy::factory(3);
const auto r = lhs + rhs;

auto ptr = cyy::object_cast< int >(r);
assert(*ptr == 5);

Automatic garbage collecting is included by using a reference counter. It's cheap to copy objects since only a reference counter must be increased. Explicit cloning (deep copy) is possible. If an object is marked to have ownership (of a resource) cloning is prohibited.

I/O: The io library creates a link to the outside world. There are building blocks for parsers to read data and serializer to write data. Some protocols are ready to use (JSON, binary, human readable, XML is coming soon). If you want to get data in and out you have to look here.

STORE: The store library acts like a simple, threadsafe key-value store. It makes heavy use of the core library - especially the lockable data type. It's extremly usefull to build up a lock hierarchy by storing tables into tables. By using C++11 lambdas it's astonishing easy to walk down the data tree (hierarchy) only locking the needed objects. Similiar to RethinkDB the store offers real time feeds. Instead of polling for changes, the developer can tell the store to continuously push updated records to applications in realtime.

VM: The vm library provides a tiny VM that continues the idea of dynamic data from the core to dynamic code. The VM implementation comes with library manager to add and remove functions at runtime.

SCHEDULER: The scheduler library works independend from the core library. It's build around the active object pattern. The best supported programming model is to work with tasks. The programmer can split the project into small tasks. These tasks can be dependend (chained), independend (async) or recurrend (by timer). The task scheduler distributes all tasks to a thread pool, monitors execution and provide a locking mechanism without mutexes. The repository contains an example project threadsafe_container to illustrate this feature.

DLOAD: The dload library is a very basic library to handle DLLs/shared libraries at runtime. It is independend from the core library. The best part is a kind of classloader for C++.

comments powered by Disqus