Saturday, December 8, 2018

Digest for comp.lang.c++@googlegroups.com - 10 updates in 4 topics

Thiago Adams <thiago.adams@gmail.com>: Dec 08 02:35AM -0800

On Friday, December 7, 2018 at 6:11:19 PM UTC-2, Mr Flibble wrote:
> Hi!
 
> Website for neoGFX side project neoTUI now up at https://neotui.com
 
Hi Flibble!
 
I am very interested in text UI!
 
Personally, I think this is much more modern than
desktop frameworks. I am talk seriously.
This is what we need on the server side. For the client
side we have the web.
I like to have an local alternative on the server side
to talk with the server apart (side-by-side) with the web
interface.
Then I think the portable console interface is good for it.
 
This is also the reason I create my conio.h for windows and linux.
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Dec 08 10:23PM

On 08/12/2018 10:35, Thiago Adams wrote:
> interface.
> Then I think the portable console interface is good for it.
 
> This is also the reason I create my conio.h for windows and linux.
 
The example application for neoGFX will be a chat client; I plan for it to
have both a GUI and a TUI front-end. The chat client will include a
daemon that can run remotely on a server and will be configurable using a
GUI or a TUI.
 
/Flibble
 
--
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who
doesn't believe in any God the most. Oh, no..wait.. that never happens." –
Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are
confronted by God," Bryne asked on his show The Meaning of Life. "What
will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery
that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a
world that is so full of injustice and pain. That's what I would say."
David Brown <david.brown@hesbynett.no>: Dec 08 02:24PM +0100

On 07/12/2018 21:06, Scott Lurndal wrote:
> do that and find in a year or two that everything is broken
> because deprecated feature was removed in the next release
> of the compiler.
 
Most of my code is project specific, and keeps the same version of the
same compiler throughout its lifetime. So I /could/ use deprecated
features like this. However, I would only do so if it were particularly
useful - which #import is not.
woodbrian77@gmail.com: Dec 08 10:51AM -0800

On Friday, December 7, 2018 at 2:06:58 PM UTC-6, Scott Lurndal wrote:
> do that and find in a year or two that everything is broken
> because deprecated feature was removed in the next release
> of the compiler.
 
As I understand it, support for #import was added, then
deprecated, then undeprecated and then deprecated again.
I'm not sure what to expect regarding #import, but I
wouldn't be surprised if it is reinstated.
 
 
Brian
Ebenezer Enterprises
http://webEbenezer.net
"Shobe, Martin" <martin.shobe@yahoo.com>: Dec 07 05:59PM -0600

On 12/7/2018 3:20 AM, Alf P. Steinbach wrote:
[snip]
 
> with ungood quality of bombs made in English factories with mostly
> female workers), and much else. But since then it's not progressed
> beyond e.g. counting lines of code as a metric of productivity.
 
Since the ISO was a re-organization of the ISA and the ISA begin in
1926, this misogynous "history" is fake. Please don't continue to spread it.
 
http://www.sis.pitt.edu/mbsclass/standards/martincic/isohistr.htm
 
Martin Shobe
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Dec 08 02:46AM +0100

On 08.12.2018 00:59, Shobe, Martin wrote:
>> productivity.
 
> Since the ISO was a re-organization of the ISA and the ISA begin in
> 1926,
 
That's irrelevant to anything.
 
 
> this misogynous "history"
 
Did you latch on to the word "female" and fail to apply any rational
thinking, or was this a more purely random choice of derogatory
adjective, a shot in the dark hoping to maybe hit something?
 
 
> is fake.
 
That conclusion doesn't follow from any premise or logic of yours.
 
 
> Please don't continue to spread it.
 
You could have looked it up, you know.
 
You were so close:
 
 
> http://www.sis.pitt.edu/mbsclass/standards/martincic/isohistr.htm
 
The site you refer to here traces the history to the US in WWII, with
further development in Britain after the war.
 
[quote]
The history behind this series of standards can be traced to the USA
during World War II. From the USA, the concept of quality assurance
spread to Europe via NATO where it evolved into the Allied Quality
Assurance Publication (AQAP). This series of docu ments discussed
everything from production efficiency to selection of suppliers. The
AQAP series were adopted by the UK Ministry of Defense for the British
Armed Forces. This series had a trickle down effect as organizations
began to require quality ass urance programs from their suppliers. The
problem was that there was much diversity in the requirements for
different organizations
[/quote]
 
I've read a review of computing history in the American publication
Scientific American, where the author, a renowned US professor, failed
to make any mention of George Boole, Augustus de Morgan, Charles Babbage
and Ada Lovelace. He started with Napoleon I think it was, skipped
England and later Konrad Zuse, I'm not sure but it's possible he also
skipped Alan Turing, made it appear that Johannes von Neumann was an
American, and that modern computing was invented in the US. That's one
example of why I'm a bit skeptical of American history writing. But I
fail now to google up a reference more in the direction of England, I'm
not sure where I got that from. However, the role of women in production
is apparently much less controversial than the very high defect rate of
English bombs; googling found any number of references for that.
 
 
> Martin Shobe
 
Cheers!, & hth.,
 
- Alf
Manfred <noname@invalid.add>: Dec 08 06:50PM +0100

On 12/7/18 10:20 AM, Alf P. Steinbach wrote:
> ultimately it's an issue of people being paid just to conform. But. In
> practice it means that for what's "best practice" in C++ one should
> better consider the outer context, like who pays, very carefully.
 
I have also witnessed the damage of code duplication - indeed it was a
maintenance problem where a fix was implemented in one place and
forgotten in another, a very common scenario.
 
But, when it comes to projects with very strict quality requirements,
one has to consider that coding "best practices" are not the highest
priority - although this may superficially seem a paradox.
 
By "very strict quality requirements" I mean e.g. systems where a
failure can actually physically harm people.
In these environments system validation becomes of utmost relevance,
hence the conservative attitude towards a system that has already been
validated.
When introducing a change in code, it is therefore understandable that
the modified code be deployed only for the specific targets that do need
it, and leave the code untouched for other targets - which results in
code duplication.
Obviously this introduces some extra maintenance burden, but depending
on the level of maturity of the project this burden can be evaluated to
be less harmful than the risk of introducing a bug in systems that have
already been validated, and that in the end would need no change - i.e.
an unjustified risk.
 
By no means I advocate that this is good practice from a software design
point of view. My point is that at a higher level it may be considered
preferable based on considerations on the whole system lifecycle, beyond
the rationale of software design only.
 
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Dec 07 03:57PM -0800

One can use a simple exchange to get a sort of work queue thing up and
running, however the use case can be interesting and simply might not be
compatible with with certain algorithms. There really is no distinction
between producer and consumer threads in this scheme. The act of
producing work, can actually consume work at the same time!
 
So, it is kind of sometime like:
________________________
atomic<work*> g_work; // let's say it already has a work item...
 
 
// push some new work
work* new_work = new work();
 
work* old_work = g_work.exchange(new_work, memory_order_acq_rel);
 
// need to see if we have any old work to process...
if (old_work)
{
old_work->process();
delete old_work;
}
________________________
 
 
Sometimes, this type of pattern does not fit in with certain use cases.
For instance, if a program expects a producer thread to just push items
into a queue, and that's it. In this type of case, a producer is NOT
expected to actually _work_ on the damn things. Well, this does not jive
here because a producer can suddenly morph into a consumer.
 
Fwiw, I should have some running example code up tonight or sometime
tomorrow.
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Dec 07 07:41PM -0800

On 12/7/2018 3:57 PM, Chris M. Thomasson wrote:
> between producer and consumer threads in this scheme. The act of
> producing work, can actually consume work at the same time!
 
> So, it is kind of sometime like:
[...]
 
Fwiw, here is a hyper simple Relacy unit test:
 
// I love this, been using it for years...
https://github.com/dvyukov/relacy
 
___________________________
// A stupid simple swap queue... ;^)
 
 
//#define RL_DEBUGBREAK_ON_ASSERT
//#define RL_MSVC_OUTPUT
//#define RL_FORCE_SEQ_CST
//#define RL_GC
 
 
#include <relacy/relacy_std.hpp>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstdlib>
 
 
#define ct_mb_relaxed std::memory_order_relaxed
#define ct_mb_acquire std::memory_order_acquire
#define ct_mb_release std::memory_order_release
#define ct_mb_acq_rel std::memory_order_acq_rel
 
 
#define THREADS 5
#define ITERS 3
 
 
struct ct_swapq
{
struct work
{
VAR_T(unsigned int) m_data;
 
work(unsigned int data) : m_data(data) {}
 
void process()
{
unsigned int x = VAR(m_data);
RL_ASSERT(x >= 0);
//std::cout << VAR(m_data) << "\n";
}
};
 
std::atomic<work*> m_head;
 
ct_swapq() : m_head(nullptr) { }
 
 
work* swap(work* n)
{
return m_head.exchange(n, ct_mb_acq_rel);
}
};
 
 
 
// Test
struct ct_swapq_test
: rl::test_suite<ct_swapq_test, THREADS>
{
ct_swapq g_mpmc;
 
 
void before()
{
 
}
 
 
void after()
{
 
}
 
 
void thread(unsigned int tidx)
{
for (unsigned int i = 0; i < ITERS; ++i)
{
ct_swapq::work* wnew = new ct_swapq::work(tidx * tidx + i);
ct_swapq::work* wold = g_mpmc.swap(wnew);
 
if (wold)
{
wold->process();
delete wold;
}
}
 
ct_swapq::work* wold = g_mpmc.swap(nullptr);
 
if (wold)
{
wold->process();
delete wold;
}
}
};
 
 
int main()
{
{
rl::test_params p;
 
p.iteration_count = 5000000;
//p.execution_depth_limit = 33333;
// p.search_type = rl::sched_bound;
//p.search_type = rl::fair_full_search_scheduler_type;
//p.search_type = rl::fair_context_bound_scheduler_type;
 
rl::simulate<ct_swapq_test>(p);
}
 
return 0;
}
___________________________
 
 
Next code will be a simple C++11 example.
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Dec 07 08:22PM -0800

On 12/7/2018 7:41 PM, Chris M. Thomasson wrote:
> https://github.com/dvyukov/relacy
 
> ___________________________
> // A stupid simple swap queue... ;^)
[...]
> #define ct_mb_acq_rel std::memory_order_acq_rel
[...]
>         return m_head.exchange(n, ct_mb_acq_rel);
>     }
> };
[...]
 
server based work flow loop, radical pseudo-code:
 
worker_thread:
_____________________
ct_swapq g_q;
 
for (;;) // shutdown process omitted for brevity...
{
work* w = g_q.swap(nullptr);
if (w) { w->process(); delete w; }
 
w = IO.get_request();
 
work* nw = g_q.swap(w);
if (nw) { nw->process(); delete nw; }
}
_____________________
 
It should work fine.
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: