Re: Schwartz counters.

From: Alf P. Steinbach (alfps_at_start.no)
Date: 06/27/04


Date: Sun, 27 Jun 2004 08:33:56 GMT


* John Harrison:
>
> "Dave Townsend" <datownsend@comcast.net> wrote in message
> news:NMudnSZt5Zt_akDdRVn-gQ@comcast.com...
> > John,
> >
> > Schwartz counters are a variation of the Singleton pattern to control the
> > lifetime
> > of a shared resource such as a file stream such that the resource is
> created
> > only
> > once on the first use, and destroyed when the last client of the resource
> is
> > destroyed.
> > A mgr class controls the shared resource and keeps track of how many times
> > the constructor
> > for the resource is called and how many times the destructor is called.
> > Here is an example to explain better than my words...
> >
> > dave
> >
>
> Thanks for the clear explanation. I was hoping for something a bit more
> sophisticated though. The original quote made it sound like it might be
> something for controlling the order of initialisation across translation
> units.

It is related. I think Andrei covered that usage in Modern C++ Design.
One problem it can solve is that while static destruction is opposite
order of construction, one may want e.g. a logging facility to exist
as long as anyone is using it; it might be instantiated late on, but
used till the end of the program.

But I totally agree with you that using a special name for something
conceptually trivial like that (although its application is not
necessary so) is in my words a case of projecting an appearance of
sophistication when the reality is mundane, where that effort by itself
degrades the communication to the point where little can be understood.

Henceforth we shall not say "smart-pointer" but "indirection-operator
based generic implemention of Handle/Body pattern with automatic memory
reclamation semantics", or perhaps "Kalasabunka-Flirrp handles", after
the well-known (?) computer scientists Kalasabunka and Flirrp.

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?


Relevant Pages

  • Re: Schwartz counters.
    ... > Schwartz counters are a variation of the Singleton pattern to control the ... > of a shared resource such as a file stream such that the resource is ... > A mgr class controls the shared resource and keeps track of how many times ... John ...
    (comp.lang.cpp)
  • Re: Venting on .NET
    ... the Dialog editor spits out a .rc file. ... as not properly naming a control), hand-editing the generated code to rename a control is ... the field of cognitive psyhcology, Alan Newell and Herb Simon], I can state that NO design ... >That's certainly true is we're talking about resource templates in the Win32 ...
    (microsoft.public.vc.mfc)
  • Re: Group Scope Question
    ... Hey Joe, ... > that group then has better control over the folks accessing the resource. ... Of course one can nest DLGs in DLGs. ...
    (microsoft.public.win2000.security)
  • Re: MFC future?
    ... all ILs assume the programmer wants less control ... ... when people look at IL-based systems today they tend to be thinking of Java ... In Java there can be serious resource management problems because the ...
    (microsoft.public.vc.mfc)
  • Re: Iraq update
    ... >>>wars in history are about population control, ... Population control or resource control? ... > Bison, Buffalo. ... > Lebanon and Israel don't have the great Cedar forests anymore. ...
    (rec.games.frp.dnd)