
24 Nov
2004
24 Nov
'04
9:51 p.m.
Hello Pavel, Thank you for the feedback, I have some things to comment: > Maybe the best way to think about it is how it could be used. > I see few common scenarios: > > 1. As message queue between producer(s) and consumer(s), > carying typed or untyped messages (with possible filtering > of these mesages). A process shared condition variable would be very useful for this to block processes when queue is empty/full, do you know any windows implementation for process-shared condition variables? I think a message queue is a must for boost. I would love also non-connection oriented message oriented ipc, something similar to datagram unix socket or a connection oriented stream ipc, like stream unix sockets. As far as I know cygwin a similar uses TCP/IP to emulate unix sockets, so I have not seen a pure windows source code anywhere. I'm working on the calling syntax, I'm thinking in something like: segment.named_new<MyType>("name") (Param1, Param2, Param3); segment.named_new<MyType>("name") [array_length](Param1, Param2, Param3); to find or create segment.find_or_named_new<MyType>("name") (Param1, Param2, Param3); segment.find_or_named_new<MyType>("name") [array_length](Param1, Param2, Param3); No throwing versions: segment.named_new<MyType>("name", std::nothrow) (Param1, Param2, Param3); segment.named_new<MyType>("name", std::nothrow) [array_length](Param1, Param2, Param3); segment.find_or_named_new<MyType>("name", std::nothrow) (Param1, Param2, Param3); segment.find_or_named_new<MyType>("name", std::nothrow) [array_length](Param1, Param2, Param3); I would like the deletion to be unique although in plan memory new[] requires delete[], : segment.delete("MyName"); //does not throw, returns true/false Do you find them appropiate? Regarding exceptions, I agree that the return value and the exception are not a good way to handle the error. If you were using throwing version, several exceptions can occur: -> bad_alloc when there is no more memory -> any exception thrown by any constructor When using create only version, if the object is already created, I suppose you would like another exception to be thrown, something like boost::shmem::already_created. The no throwing versions would return 0 if any error is found. Is that right? Regarding find_named_new function I would like to mantain the std::pair<T*, size_t> version.(not throwing, just true if found). >>>8. offset_ptr.hpp: full_offset_ptr class >>>b) The flag could be eliminated completely. > Hmm, maybe something as (ptrdiff_t)-1 or if there's some symbolic > name for such value. A char pointer could point to any byte in the segment, so (ptrdiff_t -1) would be valid. I can add a new base class for offset_ptr that considers (ptrdiff_t-1) zero, so that the user can use that pointer if he wants. >>>12. The simple algorithm to find fitting memory > Maybe if the library has interface to plug in different > algorithm (no clue now how it would look like). I will add another algorith to show that algorithm can be chosen via template parameter. __________________________________________ >>>13. Can be be possible to identify named objects >>> with something else than C string? Say >>> wchar_t* or numeral or other templated type? >> >> Do you think that the key type should be templatized? >> > Well, this is Boost ;-) Anyway, the user can create a map with the <key_type, mapped_type> using actual interface, place it with a name, and use the new map (that can be a hashed or a tree map) to obtain the same efect. > This reminds me, newest STLport beta has lock-free allocator > inside (I know just this, no more details). I will try to have a look (although it can be added later if the allocation algorithm is templatized) > Maybe the library could list those offending STLs and instruction how > to fix them manually to be useable with shmem. Such a fix should > not change behaviour of applications, right? I will add changes needed for Dinkum STL, but I don't know if publishing template lines and the changes needed can lead to any legal problem. >>>d) support for "transactions": I would like to > - transactions with isolation level 1: > - transactions with isolation level 2: Sounds like it can be a layer above shmem library, another library perhaps. I 'll wait some days to see if there are more comments on this library. After that, I'll try to rewrite some things pointed, make another allocation algorithm and change the named_new syntax. I will rewrite the documentation and post another version as soon as possible. Regards, Ion