GithubHelp home page GithubHelp logo

anidmap's Introduction

anidmap

This is a small library that will be used primarily in the Alux Operating System. It facilitates the allocation of unique identifiers and the association of these identifiers with objects.

In the context of operating systems, this could be used to allocate file descriptors, process IDs, outgoing TCP/UDP port numbers, and more.

Maps

anidmap includes a fixed-size hashmap structure HashMap for mapping objects to their identifiers. This is a subclass of the Map abstract class. In the future, I may create other methods of ID-object association, such as structures based on binary trees.

Identifiers

An IdAllocator subclass can be used to allocate unique identifiers. Currently, there are two subclasses of this:

  • The PoolIdAllocator uses an expanding memory pool to track identifiers that have been freed.
  • The StepIdAllocator continually increments a counter until it needs to wrap around. To wrap around the identifier counter, StepIdAllocator finds a chunk of unused identifiers in O(n^2) time (with a hash-map backing).

Identifier Maps

The IdMap class can be used to join the functionality of an IdAllocator with that of a Map. Since allocators may depend on a map to find unused IDs, you must use a specialized IdMap subclass for the type of IdAllocator you would like to use.

Currently, the StepIdMap and PoolIdMap classes serve as IdMap subclasses.

Dependencies

anidmap uses ansa for its locking mechanism.

The following standard headers are required:

  • <cstdint> - integer types such as int_fast32_t
  • <cassert> - assert macro
  • <cstddef> - NULL definition

Configuration

You may notice that anidmap includes a file that it does not provide itself:

#include <anidmap/lock>

You must create this include file. It must define a class called anidmap::Lock that is a subclass of ansa::Lock. The anidmap::Lock class will be used for all synchronization in the library. Usually, you will be able to achieve this using the GCC/Clang -I directive. See the lock implementation based on stdc++ in test/stdcpp-lock.cpp.

anidmap's People

Contributors

unixpickle avatar

Watchers

 avatar

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.