Git Product home page Git Product logo

simplecollections's People

Contributors

davetcc avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

simplecollections's Issues

On ARM processors use LDREX and STREX for the circular buffer for better CAS semantics on multicore boards.

On ARM every processor from Cortex-M0 upwards supports LDREX and STREX, this allows the library to be completely thread-safe on a very wide range of ARM boards, even boards with multiple cores. For now this should enable automatically for:

  • Arduino SAMD boards
  • Seeed SAMD boards
  • STM32Duino based boards.

For other processors, users could submit a PR that enabled this support for additional boards.

Some BtreeList methods should be declared as const member methods

BtreeList's various access methods that do not modify underlying data, such as getByKey, itemAtIndex, capacity, etc., should be declared as const member methods. This allows it to be used in the case where the returned object is a const list, e.g. when you want to save the cost of a list copy constructor so you return your own private list by reference but declared as const to avoid outside modification. In such a case, you should still be able to look up items, get the capacity, etc., without violating C++ qualifiers.

Add a circular buffer that works concurrently across a wide range of boards.

This will support a buffer where there is a writer position and a reader position, the writer keeps writing no matter what, even if it overwrites the read position. The reader can read whenever there is a difference between read and write position. In normal use the buffer should be sized to avoid wrapping.

Initial support will be:

ESP8266 - CAS emulated
ESP32 - uses CAS
mbed/Arduino mbed - uses CAS
AVR/MKR other - CAS emulated

Support for earlephilhower/arduino-pico boards

These boards use a different core structure to the mbed based Arduino variant, so I've used the lowlevel API available critical section for core locking while the circular buffer is ticked.

Enhancement: Support ArxSmartPtr's shared_ptr objects (Ported from BOOST to standalone Arduino)

Would love to see added support for https://github.com/hideakitai/ArxSmartPtr -- as of this moment I believe the issue is that you are one-off of a level of dereferencing, where you have a pointer to type T and then you invoke ->getKey(), which in the case of shared_ptr doesn't utilize its operator->() call since at that point it was reinterpret casted to a pointer to the shared_ptr object, thus attempting to call the shared_ptr's getKey() method (which it doesn't have).

I believe this may just be a limitation of your current design in general, tho, as it would seem it does about the same with a pointer based type, as well.

I was thinking about this exact issue actually the other day actually, and one way to implement support for this is to distinguish between pointer types and value types at the class level (where each class could do the appropriate amount of dereferencing based on T being value type or pointer/shared_ptr type) - I've seen interesting variations on splitting classes into two subclasses based on various properties. ArduinoJSON library, for instance, won't allocate a memory pool for a read-only object (since it won't be modified), but it will for the writeable object (since it might) - doesn't use const but it does suffix the name the object with Const. Even language like ObjC also do this, by having a MutableArray being write-enabled and Array being read-only (with MutableArray inheriting from Array).

Anyways, I realize it's a big ask, but it would be awesome to see support for such things added. I've included a test program illustrating the compilation error I get when I try to use a shared_ptr object directly.

#include <Arduino.h>
#include <SimpleCollections.h>
#include <ArxSmartPtr.h>
#include <assert.h>
using namespace std;

class TestClass {
public:
  TestClass(int key) : _key(key) {;}  
  int getKey() const { return _key; }
private:
  int _key;
};

void setup() {
  BtreeList<int, shared_ptr<TestClass> > list;
  auto instance = make_shared<TestClass>(0);
  list.add(instance);
  auto instanceRet = list.getByKey(0);
  assert(instance.get() == (*instanceRet).get());
}

void loop() {}

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.