tanya library 0.2.0

Seb via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Sat Feb 18 15:08:52 PST 2017


On Saturday, 18 February 2017 at 15:51:59 UTC, Eugene Wissner 
wrote:
> It isn't really a release announce, maybe a pre-release.
>
> tanya is a general purpose library, used mostly for networking 
> by me. It is an attempt to develop an alternative memory model 
> for D; 100% of the library are usable in @nogc code.

Sounds really cool!


> tanya contains an event loop, containers, an URL parsing 
> routine and alternative TCP sockets implementation, multiple 
> precision integer. The library is cross plattform, but not 
> thread-safe yet.

Do you know about eventcore [1] (event loop abstraction)?
I hope that this will soon be submitted to Phobos as everyone 
seems to be brewing their own solution and I am _not_ looking 
forward to manage to find a way to run five event loops when I 
want to use fix different libraries.

[1] https://github.com/vibe-d/eventcore

> The memory management is based on allocators. The allocators 
> are one-way compatible with std.experimental.allocator, it 
> means my allocators can be used with 
> std.exeperimental.allocator but the std.experimental.allocator 
> isn't usable with my lbirary (though it is pretty 
> straightforward to write a wrapper for phobos allocators). 
> tanya's allocators follow Bloomberg Allocator Model, see 
> discussions on BDE Allocator Model for pro and contra.

 From [2] and your API I get that the BDE API is:

     virtual void* allocate(size_type size)
     virtual void deallocate(void *address)

whereas you extended this by:

    int alignment()
    void[] allocate(in size_t size)
    bool deallocate(void[] p)
    bool reallocate(ref void[] p, in size_t size)
    bool reallocateInPlace(ref void[] p, in size_t size)

Well obviously the std.experimental.allocator protocol is more 
complicated:

     uint alignment()
     void[] allocate(size_t, TypeInfo ti = null)
     void[] alignedAllocate(size_t n, uint a)
     void[] allocateAll()
     bool expand(ref void[], size_t);
     bool reallocate(ref void[], size_t);
     bool alignedReallocate(ref void[] b, size_t size, uint 
alignment);
     Ternary owns(void[] b);
     Ternary resolveInternalPointer(void* p, ref void[] result);
     bool deallocate(void[] b);
     bool deallocateAll();
     Ternary empty();

However I would be very interested in hearing your reasons for 
not using it.
Keep in mind that std.experimental.allocator is supposed to be a 
general purpose library exactly to avoid everyone writing their 
own, incompatible Allocators ;-)
So please raise your voice as long as it's still in experimental!

[2] https://github.com/bloomberg/bde/wiki/BDE-Allocator-model


More information about the Digitalmars-d-announce mailing list