- an experimental read/write mutex... - 2 Updates
- "Modern C++ Won't Save Us" by alex_gaynor - 11 Updates
- online switch case generator for strings - 1 Update
sales@portsip.com: May 05 01:35AM -0700 Hi Chris, I'm looking for a fast read/write lock in my project, would you please share me your latest implementation then I can do benchmark and feedback. Thanks On Wednesday, February 20, 2019 at 1:56:19 PM UTC+8, Chris M. Thomasson wrote: |
"Chris M. Thomasson" <invalid_chris_thomasson_invalid@invalid.com>: May 05 03:30PM -0700 > Hi Chris, > I'm looking for a fast read/write lock in my project, would you please share me your latest implementation then I can do benchmark and feedback. Here is my latest version 0.1: https://pastebin.com/raw/1QtPCGhV (raw text link, no ads...) It should compile right up and run. If you undefine CT_TEST_FAST_MUTEX it will run the test against std::shared_mutex. > On Wednesday, February 20, 2019 at 1:56:19 PM UTC+8, Chris M. Thomasson wrote: >> On 2/17/2019 11:34 PM, mvorbrodt@gmail.com wrote: >>> On Thursday, February 14, 2019 at 2:03:43 AM UTC-5, Chris M. Thomasson wrote: [...] |
Ian Collins <ian-news@hotmail.com>: May 05 01:05PM +1200 > (RRAD Resource Release At Destruction), which may be ::free(), delete, > ::clost(int), ::freeaddrinfo, unlock... > However, such usecase is not often encountered but necessary. But when and where is the file closed? What happens if the object is passed to more than one consumer? -- Ian. |
wyniijj@gmail.com: May 04 08:21PM -0700 Ian Collins於 2019年5月5日星期日 UTC+8上午9時05分20秒寫道: > passed to more than one consumer? > -- > Ian. Sorry, typo again! Those lines should be: const char* fname="tmpfile"; My::RegFile regf(fname, O_CREAT|O_TRUNC|O_RDWR, S_IRUSR|S_IWUSR); My::AtDestroy<My::Errno,const char*> rrad(My::unlink,fname); ... A1: Good question (when and where is the file closed?) When execution leaves the scope, dtor of rrad unlink the fname entry in OS. File descriptor is closed by the dtor of regf. OS does the job correctly. A2: I'm not quite sure what the 2nd question means exactly. regf can be passed to another functions easily, by reference or by value (throu copy ctor). "by move" would be another story. rrad is meant to stay there, not to pass to any other stuff. The only chance the name rrad is used is rrad.release(), like the old smart_ptr does Now I can understand better. It might be the typo that caused confusion. |
Ian Collins <ian-news@hotmail.com>: May 05 03:31PM +1200 > A1: Good question (when and where is the file closed?) > When execution leaves the scope, dtor of rrad unlink the fname entry in OS. > File descriptor is closed by the dtor of regf. OS does the job correctly. How is what you use better than having RegFile take care of the close? What benefit is there in adding another class (which you may forget to include) to do the job? > (throu copy ctor). "by move" would be another story. > rrad is meant to stay there, not to pass to any other stuff. The only > chance the name rrad is used is rrad.release(), like the old smart_ptr does Doesn't that limit the utility of RegFile? It it was responsible for cleaning up, by adding reference counting it could be passed around, or even stored in a container somewhere. That is what RAII gives you. -- Ian. |
peteolcott <Here@Home>: May 04 11:05PM -0500 On 4/26/2019 7:48 AM, Stefan Ram wrote: > Facebook. GCC now uses C++ as its implementation language. > Chromium (browser), Firefox, and MySQL and probably a lot of > other well-known software items are written in C++ C++ is the best language where performance matters, when we take into account This perspective: https://fossbytes.com/linux-creator-linus-torvalds-c-programming-horrible/ -- Copyright 2019 Pete Olcott All rights reserved "Great spirits have always encountered violent opposition from mediocre minds." Albert Einstein |
wyniijj@gmail.com: May 04 09:14PM -0700 Ian Collins於 2019年5月5日星期日 UTC+8上午11時31分24秒寫道: > > When execution leaves the scope, dtor of rrad unlink the fname entry in OS. > > File descriptor is closed by the dtor of regf. OS does the job correctly. > How is what you use better than having RegFile take care of the close? No idea what is meant. I can only split your question into smaller chunks to understand > What benefit is there in adding another class What 'another' class did I add? > (which you may forget to > include) to do the job? What file or class did I forget to include? > > rrad is meant to stay there, not to pass to any other stuff. The only > > chance the name rrad is used is rrad.release(), like the old smart_ptr does > Doesn't that limit the utility of RegFile? What is it that limited the utility of RegFile? > It it was responsible for > cleaning up, by adding reference counting it could be passed around, or > even stored in a container somewhere. ... > That is what RAII gives you. > -- > Ian. I'm glad to hear what exactly RAII is. |
Ian Collins <ian-news@hotmail.com>: May 05 04:33PM +1200 >> How is what you use better than having RegFile take care of the close? > No idea what is meant. > I can only split your question into smaller chunks to understand Why can't RegFile do what AtDestroy is doing? RegFile should be able to clean up after its self without the need of a helper class (AtDestroy). >> What benefit is there in adding another class > What 'another' class did I add? AtDestroy >> (which you may forget to >> include) to do the job? > What file or class did I forget to include? You could forget AtDestroy. >>> chance the name rrad is used is rrad.release(), like the old smart_ptr does >> Doesn't that limit the utility of RegFile? > What is it that limited the utility of RegFile? You can't use it outside of the scope where it is created or share it with another object or thread. Consider a case where you want to open a bunch of file and store the the descriptors in a container for later use. -- Ian. |
wyniijj@gmail.com: May 04 11:55PM -0700 Ian Collins於 2019年5月5日星期日 UTC+8下午12時33分37秒寫道: > >> What benefit is there in adding another class > > What 'another' class did I add? > AtDestroy A RegFile instance is basically a file descriptor. The ctor may open/create a file or dup from another instance. So, dtor does the opposite (close it). If a file is created, ::close(int) does not remove the file. ... I guess you were suggesting that if a file is created, the dtor could do exactly the opposite thing (delete the file). But, then, the class will contain two more data members, one of which would contain file pathname(already difficult),... besides, cosiderations include 1.RegFile is not alone, belonging to SysFile class family(common vptr) 2.How to implement the copy ctor? So, conclusion, not viable, too expensive. > >> include) to do the job? > > What file or class did I forget to include? > You could forget AtDestroy. I tried, but haven't come up with any alternative. > > What is it that limited the utility of RegFile? > You can't use it outside of the scope where it is created or share it > with another object or thread. Can't figure out sensible meaning. Are you really Ian Collins? > Consider a case where you want to open a > bunch of file and store the the descriptors in a container for later use. > -- I tried using std::vector, what you are more familiar with. And...? std::vector<Wy::RegFile> farr{Wy::RegFile("abc",O_RDWR), Wy::RegFile("efg",O_RDWR)}; |
Jorgen Grahn <grahn+nntp@snipabacken.se>: May 05 07:29AM On Fri, 2019-05-03, Melzzzzz wrote: > On 2019-05-03, Jorgen Grahn <grahn+nntp@snipabacken.se> wrote: >> On Fri, 2019-05-03, Melzzzzz wrote: ... >> as locals in functions. Code with is sprinkled with smart pointers >> makes me suspicious -- IMO they should be used rarely. > So you put objects by value everywhere? I don't see exactly what you mean by "put" ... I typically pass them by (const) reference, and have a rule "the callee may not keep hold of such a reference forever". I don't mind std::unique_ptr, but I distrust std::shared_ptr. I want to know when my objects are destroyed, without analyzing the whole program. I want object lifetimes to be /designed/. (This does not mean I'd never use shared pointers under any circumstances; they're just not one of my main tools.) /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
Jorgen Grahn <grahn+nntp@snipabacken.se>: May 05 07:35AM On Fri, 2019-05-03, Ian Collins wrote: > On 04/05/2019 07:46, Jorgen Grahn wrote: >> On Fri, 2019-05-03, Melzzzzz wrote: ... >> makes me suspicious -- IMO they should be used rarely. > The code base I'm currently working in uses them a lot simply because it > is event driven and passes shared messages between threads. That sounds like a valid use case, especially if you have a smart pointer template dedicated for that use case. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
Ian Collins <ian-news@hotmail.com>: May 06 07:48AM +1200 >>> No idea what is meant. Because I misunderstood what you wrote, my questions made no sense, sorry.. -- Ian |
scott@slp53.sl.home (Scott Lurndal): May 05 09:22PM >> for a massively parallel processing system called OPUS. >In 1989? CFront? C++ in 1989 was not C++ of today. I can imagine what >that code looked like :P CFront, indeed. C with classes. Looked pretty :-) |
woodbrian77@gmail.com: May 05 02:05PM -0700 On Thursday, May 2, 2019 at 9:26:19 AM UTC-5, Thiago Adams wrote: > secret technology where you don't want to distribute the code even > in binary form or if the installation or use of the binary forms were > too complicated. It wasn't that many years ago that the "Ten Commandments" were posted in US classrooms. Now though, many, including governments, are focused on stealing technologies from others. So I'm happy with this fortress/cloud environment. Without it socialists would run me out of business. I remember Obama saying something like: you didn't build that. Really? Who do you think did? Rudolph the Red-Nosed Reindeer. Brian Ebenezer Enterprises http://webEbenezer.net |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment