Giter Site home page Giter Site logo

sophistsolutions / stroika Goto Github PK

View Code? Open in Web Editor NEW
95.0 12.0 9.0 325.2 MB

Modern C++ made easy

Home Page: http://og.sophists.com/Stroika/

License: MIT License

C++ 96.20% C 0.12% Shell 0.61% Perl 0.40% Makefile 2.24% Batchfile 0.01% Dockerfile 0.21% Rez 0.22%
json datastructures threadsafe thread-pool xml web-app linq upnp performance streams

stroika's Introduction

Stroika v2.1

Stroika is a modern, portable, thread-savvy, C++ application framework. It makes writing high performance C++ applications easier by providing safe, flexible, modular building blocks.

Stroika provides a layer on top of the Standard C++ Library, with simpler to use (higher level) classes, more safety checking guarantees, and a wider domain of applicability. But those Stroika classes seamlessly integrate with standard C++ classes, and your code can easily use as much of either library as preferences dictate.

Stylistically, Stroika differs from the Standard C++ Library, boost, and many other C++ libraries, in that it (relatively) embraces object oriented abstractions over template-based genericity (see Stroika-Approach-To-Performance.md). The abstraction of type hierarchies is better suited to how people reason, and templates and concepts - while powerful - can be fiddly and obscure programmer intent. Also, Stroika emphasizes separation of interface from implementation: carefully documenting the interface in the headers, and separating the implementation to other files.

Stroika is comprised of 2 layers: the Foundation, which provides building-block classes applicable to most applications, and a series of domain specific Frameworks which provide a rich collection of code in different domains.

alt text

The Frameworks depend on the Foundation; Foundation modules frequently depend on each other; but Foundation layer code contains no dependencies outside of the Foundation (except on the Standard C++ Library, and various ThirdPartyComponent libraries optionally included or referenced, like openssl).

Quality

  • Nearly all public interfaces and methods are well documented; implementations are clear and well commented.
  • Thoroughly integrated assertions (including thread-safety assertions) help document and enforce usage patterns (without performance cost in production builds).
  • Each release is tested with Valgrind (helgrind, memcheck), Google Sanitizers (TSAN, UBSAN, and ASAN), Github CodeQL, and a variety of platforms and compilers, as well as a large body of regression tests (including most documentation examples) to help assure library correctness.
  • Sample applications help show common use cases (like building a web server into your app to deliver web-service content and APIs).
  • Quick start using pre-built Docker containers (for Windows, and Linux).

Stroika Foundation provides

  • Cache classes (a variety of different caching/memoizing strategies directly supported).
  • Characters classes (simpler to use - especially with UNICODE - Strings class, with functional style mappings - to ToString<template>() for most Stroika objects).
  • Container classes (Collection, Queue, Mapping, Sequence, Set, and much more, each with rich variety of backend implementations).
  • DataExchange (VariantValue, rich collection of data format serializer/deserializers - like JSON, object to/from serialization mappings, and much more).
  • Execution pattern classes (external process runner, synchronization patterns, blocking queue, thread pools, and much more).
  • Networking support (high level socket wrappers, Web client fetching).
  • Simple, elegant streams library, with adapters for cryptography, compression, text transforms, etc.
  • Seamless integration (object oriented wrappers respecting Stroika's safety and adapter rules) with many important libraries , including: boost, libcurl, lzma sdk, openssl, sqlite, xerces, zlib (e.g. wrap a compression stream - using for example zlib).
  • and more...

Stroika Frameworks provides

Trade-offs

Stroika's biggest strength is also its biggest weakness:

  • There are smaller, more focused libraries that do many of the things Stroika does. Being single purpose is a form of modularity (good) and allows for easy adoption/integration. But libraries that do anything of any complexity must create their own infrastructure for a wide variety of building block problems (e.g. Xerces has its own stream classes, pistache date classes, etc). And if you have two such libraries, they are unlikely to interact seemlessly, and their support classes (for stuff like date and streams above) certainly won't.
  • Stroika takes the approach of building its functionality in layers, leveraging other components (e.g. Streams and Containers) in lower layers (as well as standardized C++ libraries). This slightly increases the cost of adopting Stroika for something small (because pulling one thing in pulls many things in), but then pays dividends as you use it to accomplish a second or third task.

Versions

  • Stroika v3 development has started, and requires C++20 or later.

  • Stroika v2.1 is stable (in maintainance), and requires C++17 or later. Version 2.1 also conditionally supports many C++20 features (such as three-way-comparison etc, if available).

  • Stroika v2.0 is very stable, and requires C++14 or later. Stroika v2.0 is used to power a wide variety of open source and commercial applications.

Compilers / Platforms regularly tested/supported

  • Linux, MacOS, Windows

  • Stroika v2.1

    Tested on x86, arm (+m1), gcc 8 thru gcc 12, clang 6 thru clang 14, Visual Studio.Net 2017, Visual Studio.Net 2019 and Visual Studio.Net 2022, XCode 13, 14, 15.

  • Stroika v2.0

    Tested on x86, arm, gcc 5 thru gcc 8, clang 3 thru clang 6, XCode 8 thru 9.

CI System Integration

Random Features

  • Vanilla make based builds
  • Portable API (targets windows/mac/unix), and multiple processors

Summary

For more details on individual release changes, see:

    Release-Notes.md

"Getting Started", build instructions, design and other documentation:

     Documentation/

Looking through the samples is also a good way to start:

    Samples/

Please report bugs/issues at:

    http://stroika-bugs.sophists.com

stroika's People

Contributors

jpringle13 avatar kjax avatar lewispringle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stroika's Issues

valgrind/Linux issue with threads - probably real bug

clang++ / valgrind issue

CLANG+++++

[](17 seconds) [34] Foundation::Execution::Threads (../Builds/DefaultConfiguration/Test34)
[Succeeded](0 seconds) [35] Foundation::Execution::Other (../Builds/DefaultConfiguration/Test35)

(tresting – thjis may only fail with enable-trace-to-file and if so – it maybe an issue with trace messages (to file) durinag  a thread abort callback (signal)

valgrind -q --track-origins=yes --tool=memcheck --leak-check=full --suppressions=DefaultValgrindSuppressions.supp ../Builds/DefaultConfiguration/Test34

issue seems to be iterating through contianers from signal handler – maybe use stl directly for this?

Further improve valgrind testing/usage

Make it easier to run regtest for mem leaks, building a no-block-allocation build or adding knowlege of our block allocation system to valgrind (there are extension points for this).

IterablefromIterator<> cleanup

I THINK IterableFromIteraotr<> now documented enough to make this clear.

1>  I can use IterableFromIteartor<> tdirectly – and use its CONTEXT_FOR_EACH_ITERATOR feature – passing in the base iterator – or even the base iterable (mapping) to call make iterator on (probab;ly better).

 And/Or I can fix Creategeneraotr so that COULLD be used if I want.
It needs its API changed to function<function<…optkna>>> and hten the context object ??? Maybe I don’t have enuf. Maybe need a code hook? Or mayben the virtual (void/void variant where I call Make my own iterator) is good enuf.

CLEANUP CODE>…

WaitableEvent::TryWait

Maybe add TryWait() on waitable event – like Wait() – but returns bool instead of throw, and then redo that TryWait as base, and do Waits() that throw is simple inline wrappers.

SafeSequence<> - maybe approach to thread safety

 maybe “SafeSequence<
“SafeSequence<> “ : Sequence<> - and that mimics each API and assignemt. For ALL – its thressafe rep. But SafeSequence (and SafeXXX for each subclass) – does envelope threasasafety. A bit like my experimental Contianer::Optional<> code.
o Then – ASSIGNEMNTs all work for data mebers (they are all safe) – but the args to functions aren’t and don’t pay costs!!!

Container CTOR optimization

Container CTORs that call AddAll() CAN do variant that optimizes – doesn’t do LOCKING – since one ref in CTOR. That can make a number of important use cases much better!

Sequence<>InsertAt/Insert

Review SequenceAPI – DOCUMENT that Insert() is basically InsertAt ();
Sequnce::Insert (should have overload taking an iterator to insert at that point refered to by iterator). Like Insert (it.CurrnetIndex()); But even more uimportant ehre cuz we don’t (yet) have it.CurrentIndex()

Bijection read validator

 Make sure bijection has ‘validator’ used in reading in data so it doesn’t crash if given bad data but throws.

PathName class

Make PathName a class with String CTOR (no explicit). Then make various public functions in that module methods.

Do DEPRECATED for exiingt public functions there.

Mapping<>::Image

Add method Iterable Image () - returns a set (maybe say return set not iterable?) of items

  •          which are the 'target' of this mapping (all the VALUES collected in a set). Note in docs - range
    
  •          is the containing set of plusaible possible values, but image is the set of actual values
    

Possible thread safety / cleanup/performance change (containers)

 New TEMPLATED optional params to CONCRETE container likes like Mapping_Array<> LOCKER.
o One value will be
 Std::mutex
 Execution::SpinLock
 ExternallySynchonized
• (but no lock SIMILAR to SpinLock except in RELASE mode does nothing, but in DEBUG mode sets falg on log but asserts not already set, and unlock unsets falg
• So caller can create an EXNTERALLYSYNCHONZIED (UNLOCKED) container instance, and get in debug mode checking that its threadsafe, but in real runtmode (release mode) runs as fast as possible (no locking)

DOCUMENT RATIONALE FOR ITERATOR OWNER

DOCUMENT RATIONALE FOR ITERATOR OWNER:

Iterators iterate over something (if not in reality, at least conceptually

 When you iterate over an interable, its illegal to deletet that iterable. However, the underlying REP may be deleted/unreferenced (dealt with how??? – assigned in other threads while iterating – tahts what new XXX #define is for)
 But remains ILLEGAL to delete the iterator container until all objects iterating over it
 We LOGICALLY are iterating of an iterable container, but in fact, behind the scenes – are itearing over iterep rep shared_pointes. The reason the sematncs of owners are important, ius becasuse when we do shared_rep cloning (break references) – we have to be able to re-assocatied running iterators with the RIGHHT iterable rep.

_SafeReadWriteRepAccessor optimized so doesn’t do needless copy

 Make sure _SafeReadWriteRepAccessor optimized so doesn’t do needless copy back
(really already done but must do optimziatio so don’t copy of refcount != 1 , but if !=2 and oldrep= newrep (ro close)…

>>> GETREP STRING COUNT 1 VERSUS 2 THING.
    I THINK SAFE IF WE SAVE
    Cnt = getRefCnt()
    If (cnt > 2 or (cnt == 2 and filterable->get() != facessor.get ()) {
        Breakreferences\    
    }
    // only risk is before entry to code – refcount WAS 2 (two real diff owners and we need to clone)
    // and our envelope gets overwritten before we do this check (very small window) – but we check count  and THEN check if ptrs diff then we must breakref. Reason != test Ok is no way to have frep.get () go back to pointing to us cuz only refptr is hidden in accessor (til end).

Consider adding IDM (identity management) Framework

Consider IDM (identity management) Framework
 Identity Objects
o GUIDS(opaue)
 Permission Objects
o Opaue
 Integrate with third party systems to find identities (LDAP, RADIUS, OpenID, SSL-ClientClient)
 Integrate with third party systems to store permissions
 See general enough to replace HFWS impl
 Consider needs of Block – and see if what I can come up with is sufficient for them (and maybe suggest they use this)
 Provide private impl of ID->Permissions mapping (simple table) and lookup to gen permissions tokens (objects0
 Framework for validation of permissions (given identities)
 Integrate with web-framework

_SafeReadWriteRepAccessor DTOR makeiterator reace?

Document race with _SafeReadWriteRepAccessor DTOR and makeIteraotr

NOTE – conflict between SafeReadWriteAccessorRep and MkaeIterator() – race – no interlock – so you can get replaced rep object which loses iterator rep!!! tracking!!!

code to review

Why
template
inline Sequence::Sequence (Sequence&& s)
: inherited (static_cast < inherited&& > (s))
{
_AssertRepValidType ();
}

DON’T UNDERSTAND WHY static_cast<inherited&&> needed on windows ??? sometimes – instead of move<inhierted>

Major rework of exceptions support/exceptions classes

SPEND A LITTLE TIME THINKING ABOUT EXCEPTION STUFF
>> first read BS (stroustprup) book
 And probably next make StringException subclass from std::exception
 And make sure all my excpetions (or most) subclass of StringException
o (maybe rename StringExcpetion to just Exception)

 ExceptionPropagateHelper must be redone using new C++11 features

CheckedConverter_ValueInRange exception cleanup

        typename RANGE_TYPE::ElementType  CheckedConverter_ValueInRange (typename RANGE_TYPE::ElementType val, const RANGE_TYPE& r)
        {
            typename    RANGE_TYPE::ElementType useVal    =   Private_::CheckedConverter_Range_Helper_Pinner_ (val, RANGE_TYPE::TraitsType::kLowerBound, RANGE_TYPE::TraitsType::kUpperBound);
            if (not (RANGE_TYPE::TraitsType::kLowerBound <= useVal)) {
                Execution::DoThrow (BadFormatException ());
            }
            if (not (useVal <= RANGE_TYPE::TraitsType::kUpperBound)) {
                Execution::DoThrow (BadFormatException ());
            }

…. Throw more informative exception saying value n outside range a..b.

block allocation docs

write docs on block allocation versus blockallocated versus blocaklocator

add todo to amke my blockaklocator work wtih stl.

doc advnates s of using blocka;locatored macorso etc

make skel

BUILD SKEL ½ working. Since in the middle of it, nicet o really get working.

Review Boost

Experiment with and review Boost. Consider if/how to harmonize/integrate with Stroika

Mapping [] syntax leads to confusing bugs

SYNTAX
Mapping<String, VariantValue> tunersObjMap = topLevelObjMap[L"Tuners"].As<Mapping<String, VariantValue>> ();
Mapping<String, VariantValue> newTunersObjMap;
for (KeyValuePair<String, VariantValue> ti : tunersObjMap) {
Mapping<String, VariantValue> thisTunerMap = ti.fValue.As<Mapping<String, VariantValue>> ();
thisTunerMap[L"TECCurrentUpperBound"] = 6.0; //???
newTunersObjMap.Add (ti.fKey, thisTunerMap);
}
topLevelObjMap[L"Tuners"] = newTunersObjMap;

compiles but does wron thing.
Maybe have topLeve[] return const ref? advantage is then above cont compile. Deistangave is wrong semantics for threads…

ProcessRunner String arguments...

ProcessRunner requires args of SDKString. Probably a mistake. At least add overload taking string. Then maybe deprecate the SDKString version.

Consider/cleanup qStroika_Foundation_Traveral_IterableUsesStroikaSharedPtr

 qStroika_Foundation_Traveral_IterableUsesStroikaSharedPtr
o ….
o Add define for Iterables_Support-Threadsafe-Copy
o Add tempalted wrapper on any SHAREDPTR to support threadsafe copy (using threadlocks and uniuu_lco, two locks, and the lock function.
o Test with defined one way or the other (define for theradsafe) and compare performance numbers. Then decicde what todo.

DOCUMENT/IteratorOwner

>>> REDOCUMENT WHY WE HAVE THIS – AND PROBABLY DON’T LOSE BUT DOCUMENT ONE WAY OR OTHER OTHER WHERE WE DECLARE ITERATOROWNER!!!

“ITERATOR CONCEPTUALLY ITERATING OVER ITERABLE. THING ITERATING OVER NOT LOGICAL TO LOSE. BUT magic with reps is HIDDEN. Sharedptr stuff is just to do that hidden rep sharedptr magic”

PROBBALY LOSE ITERATOROWNER SUTFF /*
* NB - the suggestedOwnerID argument to MakeIterator() may be used, or ignored by particular subtypes
* of iterator/iterable. There is no gaurantee about the resulting GetOwner() result from the
* iterator returned.
*
* \em Design Note
* It might have been better design to make the argument to Iterable::Rep::MakeIterator ()
* be owner instead of suggestedOwner, and then require that it get tracked. But that would
* have imposed a memory (and copying) overhead on each iterator, and the current
* use cases for iterators dont warrant that.
*
* I think its good enough that particular subtypes - where tracking an owner makes sense and
* is useful, we be done. And when not useful, it can be optimized away.
*/
virtual Iterator MakeIterator (IteratorOwnerID suggestedOwner) const = 0;

• But thinkout carefully, and probably do one single remove in one commit so easier to REVERT if I decide I was wrong…

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.