Friday, May 19, 2017

Digest for comp.lang.c++@googlegroups.com - 25 updates in 8 topics

Bonita Montero <Bonita.Montero@gmail.com>: May 19 10:15AM +0200

> No, you are wrong. What you wrote is _not_ correct when the HANDLE is
> hooked up to IOCP. ...
 
Read the article I referred to; it isn't about IOCPs.
Bonita Montero <Bonita.Montero@gmail.com>: May 19 10:27AM +0200

> Afaict, you are not waiting on that event to complete before you bind
> the file the IOCP. So, you do not know if the write was even finished
> before you start issuing reads.
 
Extending the file is done always synchronously; look at the MSDN-doc.
"Chris M. Thomasson" <invalid@invalid.invalid>: May 19 06:51AM -0700

On 5/19/2017 1:15 AM, Bonita Montero wrote:
>> No, you are wrong. What you wrote is _not_ correct when the HANDLE is
>> hooked up to IOCP. ...
 
> Read the article I referred to; it isn't about IOCPs.
 
But, you used IOCP in your code?
"Chris M. Thomasson" <invalid@invalid.invalid>: May 19 06:53AM -0700

On 5/19/2017 1:27 AM, Bonita Montero wrote:
>> the file the IOCP. So, you do not know if the write was even finished
>> before you start issuing reads.
 
> Extending the file is done always synchronously; look at the MSDN-doc.
 
You used async IO and failed to wait on the event in your code.
"Chris M. Thomasson" <invalid@invalid.invalid>: May 19 09:35AM -0700

On 5/19/2017 1:15 AM, Bonita Montero wrote:
>> No, you are wrong. What you wrote is _not_ correct when the HANDLE is
>> hooked up to IOCP. ...
 
> Read the article I referred to; it isn't about IOCPs.
 
I did read it. I never really liked using OVERLAPPED with the event.
Also, never like using completion routines.
 
Imvho, IOCP is much, much better.
"Chris M. Thomasson" <invalid@invalid.invalid>: May 19 09:38AM -0700

On 5/19/2017 6:53 AM, Chris M. Thomasson wrote:
>>> the file the IOCP. So, you do not know if the write was even finished
>>> before you start issuing reads.
 
>> Extending the file is done always synchronously; look at the MSDN-doc.
 
That like of thinking is dangerous.
 
> You used async IO and failed to wait on the event in your code.
 
How can you be absolutely sure of that since its in async mode?
 
Also, at least add a CT or something for proper quoting. I feel as if I
am beating a dead horse or something horrible like that. I see that you
are using Thunderbird, whats going on here?
 
;^o
ram@zedat.fu-berlin.de (Stefan Ram): May 19 03:36PM

>I know how to do it with a for-loop of course, but would like to know
>how to do it with std-functions.
 
::std::for_each, SCNR.
ram@zedat.fu-berlin.de (Stefan Ram): May 19 04:22PM

>but how? for_each works only for ONE object, right? You cannot copy from
>one vector to another using that I think.
 
It's contrived, but possible.
 
#include <algorithm>
#include <chrono>
#include <initializer_list>
#include <iostream>
#include <iterator>
#include <ostream>
#include <random>
#include <string>
#include <vector>
 
using namespace ::std::literals;
 
int main()
{ struct person0 { int age{ 0 }; ::std::string name; };
struct person1
{ int age{ 1 }; int height{ 0 };
::std::string name; ::std::string mobile; };
::std::vector< person0 >vector0( 10 );
::std::vector< person1 >vector1( 10 );
 
::std::for_each
( ::std::cbegin( vector0 ),
::std::cend( vector0 ),
[ &vector0, &vector1 ]( person0 const & p0 )
{ auto offset = &p0 - &vector0.at( 0 );
auto & target = vector0.at( offset );
target.age = p0.age; } );
 
::std::for_each
( ::std::cbegin( vector1 ),
::std::cend( vector1 ),
[]( person1 const & p1 )
{ ::std::cout << p1.age; } );
 
::std::cout << '\n'; }
ram@zedat.fu-berlin.de (Stefan Ram): May 19 04:28PM

>auto & target = vector0.at( offset );
 
There should be a »1« above instead of the »0«.
JiiPee <no@notvalid.com>: May 19 04:14PM +0100

say I have a 2 structs
 
struct Person
 
{
 
int age;
 
string name;
 
};
 
 
struct Person2
 
{
 
int age;
 
int height;
 
string name;
 
string mobilenumber;
 
};
 
and vectors:
 
vector<Person> persons;
 
vector<Person2> persons2;
 
// add 10 items into persons ....
 
// add 10 items into persons2 ....
 
 
Now, which std-function I can use to copy *only* the age-values from
persons vector into persons2?
 
I was thinking using std::transform, but could not yet find how. I need
to use some other std function?
 
I know how to do it with a for-loop of course, but would like to know
how to do it with std-functions.
 
thanks
JiiPee <no@notvalid.com>: May 19 04:47PM +0100

On 19/05/2017 16:36, Stefan Ram wrote:
>> I know how to do it with a for-loop of course, but would like to know
>> how to do it with std-functions.
> ::std::for_each, SCNR.
 
but how? for_each works only for ONE object, right? You cannot copy from
one vector to another using that I think.
qak <q3k@mts.net.NOSPAM>: May 19 12:40PM

David Brown <david.brown@hesbynett.no> wrote in
 
> Caches work on a line at a time - typically something like 16 to 64
> bytes long. Details will vary from processor to processor, and can be
> different for different cache levels.
 
How the cache system works for decoding video, is the data cache is filled
with previous frames which are not needed again? If I reopen the movie with
NO_CACHE flag, then immediately close it, I would find the file cache near
empty, so everything was evicted to have room for the movie.
Would so much code to decode a frame that the next frame will find all the
code cache is filled with now useless code?
Thanks for sharing.
David Brown <david.brown@hesbynett.no>: May 19 04:06PM +0200

On 19/05/17 14:40, qak wrote:
> Would so much code to decode a frame that the next frame will find all the
> code cache is filled with now useless code?
> Thanks for sharing.
 
You are mixing up a number of concepts here.
 
First, you are talking about an operating system's file or disk cache
here. That is not directly related to a processor's caches (though they
are both caches).
 
Secondly, you are talking about data caching - the thread here has been
about instruction or code caching. When playing a movie, the data
changes from frame to frame (or block to block, when it is compressed).
Once a block has been played, you don't need it again, and it will get
dropped from caches (processor caches, and OS caches). But the code
used to interpret that data stays the same, and you want that to stay in
your instruction caches.
scott@slp53.sl.home (Scott Lurndal): May 19 02:08PM

>> different for different cache levels.
 
>How the cache system works for decoding video, is the data cache is filled
>with previous frames which are not needed again?
 
That depends entirely on the algorithm that is decoding the
video and whether it is hardware assisted or not. If software
is doing the decoding, then unless it uses non-temporal operations,
it's likely that the encoded and decoded data will both occupy
cache lines. The cache replacement algorithms generally select
the least-recently used line for replacement.
 
 
> If I reopen the movie with
>NO_CACHE flag, then immediately close it, I would find the file cache near
>empty, so everything was evicted to have room for the movie.
 
The File cache (maintained by the kernel) is unrelated to the data cache
which David was discussing. The File cache is simply otherwise unused
memory regions (generally discontiguous pages), while the data cache is
a high-speed caching structure located between memory and the processor.
 
An intel processor, for example has three levels of
cache between the processor and memory. The cache closest to
the processor (L1) is also the fastest at about 4 cycles load-to-use
latency (1.3ns @3ghz); this cache is the smallest with 2Kbytes
for data and 32Kbytes for instructions. The next level of cache
(L2) is around 256KB and has a longer latency (perhaps 10ns), while
the third level of cache (which is shared by all processors) can
be up to 25MBytes, but with even longer latency (perhaps 30-40ns).
DRAM latency is in the 50-150ns range depending on many factors
including the speed and width of the memory bus and whether the
memory is local or remote to a given processor socket.
"Chris M. Thomasson" <invalid@invalid.invalid>: May 18 08:58PM -0700

On 5/16/2017 5:05 PM, Mr Flibble wrote:
 
> My upcoming C++ game/GUI library/framework "neoGFX" now has a wiki:
 
> http://neogfx.io/wiki/index.php/Main_Page
 
> neoGFX version 1.0 is about 75% complete at this stage.
 
Very nice! Thank you.
fir <profesor.fir@gmail.com>: May 19 02:04AM -0700

W dniu środa, 17 maja 2017 02:06:10 UTC+2 użytkownik Mr Flibble napisał:
 
> http://neogfx.io/wiki/index.php/Main_Page
 
> neoGFX version 1.0 is about 75% complete at this stage.
 
> /Flibble
 
give more details on details implementation (something usefull for someone who like to learn something interesting) then it would be interesting post
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: May 19 02:13AM -0700

fir wrote:
> give more details on details implementation (something usefull for
> someone who like to learn something interesting) then it would be
> interesting post
 
The usefulness seems obvious, fir. An unencumbered native toolkit to enable
rapid prototyping and development of OpenGL-based GUI apps.
 
Have you seen the page?
 
https://github.com/FlibbleMr/neogfx
 
Thank you,
Rick C. Hodgin
fir <profesor.fir@gmail.com>: May 19 06:33AM -0700

W dniu piątek, 19 maja 2017 11:13:57 UTC+2 użytkownik Rick C. Hodgin napisał:
> rapid prototyping and development of OpenGL-based GUI apps.
 
> Have you seen the page?
 
> https://github.com/FlibbleMr/neogfx
 
get off bad idiot rick - i dont want to feed abusers
 
as to this think im a bored man, and would be eventually able to read something 'core' and interesting about it here on the group (like what was hard, what was easy, what is important, what is interesting)- but to bored to
read in into it as one of thens of thousands anonymous projects over the net
 
(ps dont take this post as to encourage
to conversation bad idiot abuser rick, this is not to bad idiot abusers but to the more intellectually healthy part of this group ONLY (if it is still here after all that your zomboid work) )
alexo <alessandro.volturno@libero.it>: May 19 03:19PM +0200

Il 18/05/2017 20:25, Paavo Helde ha scritto:
 
> and #include it in the end of your MyClass.h file. The ultimate goal of
> most users of your class is to know as little about it as possible, so
> they will happily skip everything marked "implementation details".
 
I'll probably never have the need to hide portions of code, because I'm
a lover of computer programming and I write just stupid things like a
stack, a queue or simply a linked list for didactical personal
purpouses, still learning C++. Those errors allarmed me, but evidently
they were not due to a misunderstanding of some programming principle
rather than to an implementation choice of a language feature.
 
Every time I was in the need of help I wrote on this newsgroup and I've
always had my question solved. I thank you all.
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: May 19 03:33AM -0700

We all have sin. Sin places us under judgment and separates us from
God. Sin is the embracing of things which run contrary to the way our
universe was designed. It is therefore a type of cancer against
creation, eating away at what was given us by God, eating away at what's
right, true, and proper, all of the things which lead to our natural
love and growth as God intended.
 
Jesus came to the Earth to change that. He came to meet us where we
are (in our sin, under punishment and condemnation because of it),
and make a way back to righteousness for us.
 
Jesus came to the Earth to forgive our sin, restore us from judgment,
to transform our life, begin the process of healing, and guiding us
from this day forward away from Satan's traps and snares, and toward
the right, holy, true, and proper things of God.
 
How virtuous is a virgin bride kept purposefully true for her future
husband, compared to the bar room floozy who goes home with a new guy
every week?
 
Jesus wants to restore us from our sinful state, transforming us to a
perfect and spotless creation, so that we can be with Him in Heaven,
free from the rigors and burdens of this sin-laden world.
 
He wants to make all things new for you.
 
He won't force Himself on you, but respects our choice, the choice He
gave you as a free and true ability to choose. But for all who will
hear His call and come to Him asking forgiveness for their sin, to them
He gives the right to become children of God.
 
We were created in His very image and likeness. He is One, being God
the Father, Son, Holy Spirit. Likewise we are three-fold, and we are
one: soul, body, spirit.
 
Sin separates us from God because we die spiritually (eternally). But
Jesus forgives our sin by what He did at the cross. He went there
condemned under man's laws, yet innocent before God. This made Him
able to transfer our sin onto Himself so that we could be set free
from our horrific state because of sin.
 
There is no greater gift imaginable. God is literally offering you
eternity for the acknowledgement of your sin, and the asking of
forgiveness from it. He wants you to live on, thriving in the fullest
richness that is the sum total of you, unencumbered by Earthly
limitations, in a body like the angels that is always young, strong,
beautiful, and operating at the top of ability.
 
No judgment. No condemnation. Only the gift of life eternal, and
direct fellowship with God Himself. Face to face, unencumbered.
 
Jesus wants you to ask Him to forgive your sin. I pray you do. You
are a remarkable and special creation of God, and He has big plans for
you on the Earth, and in eternity. I would like to see you in Heaven.
 
Love you,
Rick C. Hodgin
legalize+jeeves@mail.xmission.com (Richard): May 19 12:52AM

[Please do not mail me a copy of your followup]
 
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> spake the secret code
>wit, their documentation has a host of instances of invalid `void main`.
>Not to mention the Microsoft monstrosities such as `tmain`. These are
>beginner mistakes. And they're all over the place at MS.
 
If you change the above "invalid code as at Microsoft" to read
"invalid code as shown in Microsoft documentation and samples" then I
would agree with you.
 
Having met many MS engineers (mostly 3D graphics dudes), I know that
the code that they write is just fine.
 
The code appearing in samples and documentation is often written by
interns or contractors and doesn't represent the actual engineering
practices at MS, beyond some superficialities like identifier
conventions.
 
James McNellis (who works at MS) talks about this a little bit in his
CppCon talk on modernizing a legacy code base.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
legalize+jeeves@mail.xmission.com (Richard): May 19 12:53AM

[Please do not mail me a copy of your followup]
 
Bob Langelaan <bobl0456@gmail.com> spake the secret code
 
>I teach a beginner C++ course and have taught my students that they
>should minimize the use of the break; and continue; statements.
 
Minimizing is fine. Avoiding as a rule is silly. Do you not teach
them Duff's Device?
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
legalize+jeeves@mail.xmission.com (Richard): May 19 12:56AM

[Please do not mail me a copy of your followup]
 
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> spake the secret code
 
>It would not be a good idea to use it as an authority on anything C++.
 
>Don't know about MISRA but I suspect the same story: a special purpose
>thing.
 
I don't consider either of those guides authorities on anything but
their own specific development circumstances. For instance, the
Google guide is the authority on C++ coding at google, but not for
much else. Even then, if you contribute to clang while at google, the
google style guide does not apply, it's the clang style guide that
applies :).
 
Still, it is useful to read these documents because it gives a set of
rules that these groups feel are useful.
 
If your team doesn't know what rules they should adopt, it's a good
starting point for discussion, but I wouldn't blindly follow them just
"because muh Google".
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>
Cholo Lennon <chololennon@hotmail.com>: May 18 10:35PM -0300

On 05/18/2017 12:06 PM, David Brown wrote:
 
> It is there for the same reason as the annoying extra ::, the ugly,
> weird and unnecessary initialisation of variables like "int miles {};",
> and the strange bracketing style.
 
I totally agree with you! In my 25 years with C++ I've never felt the
necessity to use ::std, indeed, I never found a namespace named "std"
other than the defined by the standard library. Stefan has this kind of
paranoia (TM): in 'comp.lang.java.programmer' for example he posts code
where standard Java types are prefixed with the package 'java.lang'
(java.lang.String, java.lang.Integer, etc). Nobody does that! it's not
necessary (there are some situations related to Java class loaders, but
IMO, they are just corner cases).
 
And finally, yes, his bracketing style is really weird, never seen :-O
 
> homework code themselves rather than copying and pasting it from the
> internet - by encouraging this unique style that is different from
> everyone else, students will be forced to re-write anything they copy.
 
It's a good theory :-)
 
--
Cholo Lennon
Bs.As.
ARG
Gareth Owen <gwowen@gmail.com>: May 19 06:44AM +0100

>>should minimize the use of the break; and continue; statements.
 
> Minimizing is fine. Avoiding as a rule is silly. Do you not teach
> them Duff's Device?
 
Unless they're saying "Do not write opaque nonsense like this unless
you have measured and literally every cycle is critical", they
absolutely shouldn't be teaching Duff's Device.
 
It's like teaching Civil Engineering based on the Leaning Tower of Pisa.
If programmers thought more like engineers and less like close-up
magicians - desperate to impress with their sleight of hand - the
world's software would be in a lot better place.
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: