Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: tom@tromey.com
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC 0/6] Demangle minimal symbol names in worker threads
Date: Wed, 13 Mar 2019 15:38:00 -0000	[thread overview]
Message-ID: <83muly3htw.fsf@gnu.org> (raw)
In-Reply-To: <83lg1k4vhx.fsf@gnu.org> (message from Eli Zaretskii on Tue, 12	Mar 2019 05:33:30 +0200)

> Date: Tue, 12 Mar 2019 05:33:30 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> CC: gdb-patches@sourceware.org
> 
> > I asked around and learned that std::thread should work fine if you have
> > winpthreads, which apparently is used by default for mingw-w64.
> > 
> > I don't actually know much about the mingw world, so I don't know if
> > that is good enough or not.  Could you say?
> 
> I could try.

Here's the answer.  The simple test program attached at the end
doesn't compile:

  D:\usr\eli\data>g++ -c ./threaded-hello.cc
  ./threaded-hello.cc: In function 'int main()':
  ./threaded-hello.cc:12:8: error: 'thread' is not a member of 'std'
     std::thread t1(call_from_thread);
	  ^~~~~~
  ./threaded-hello.cc:12:8: note: suggested alternative: 'tera'
     std::thread t1(call_from_thread);
	  ^~~~~~
	  tera
  ./threaded-hello.cc:15:3: error: 't1' was not declared in this scope
     t1.join();
     ^~
  ./threaded-hello.cc:15:3: note: suggested alternative: 'tm'
     t1.join();
     ^~
     tm

So I think only MinGW64 might have support for std::thread,
mingw.org's MinGW (which is what I'm using) definitely doesn't.

> But regardless, I think we should allow for ports whose
> std::thread is not up to the task, because evidently this is a
> problematic area of libstdc++.  It is IMO better to allow running this
> code in a single thread than breaking the entire build on some
> platform because other platforms might benefit from multiple execution
> cores.

This is still true.  We could detect at configure time that
std::thread isn't supported and revert to serial alternative code
instead.  Is that reasonable?  If that is deemed too much of a
maintenance burden, I could perhaps, with some guidance, implement a
simple replacement using Win32 primitives, if all we need is to start
a thread and then do the thread-join thing.  Let me know what you
think.

Here's the program I used to test this:

#include <iostream>
#include <thread>

//This function will be called from a thread

void call_from_thread() {
  std::cout << "Hello, World" << std::endl;
}

int main() {
  //Launch a thread
  std::thread t1(call_from_thread);

  //Join the thread with the main thread
  t1.join();

  return 0;
}


  reply	other threads:[~2019-03-13 15:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-09 17:23 Tom Tromey
2019-03-09 17:23 ` [RFC 6/6] Demangle minsyms in parallel Tom Tromey
2019-03-09 17:23 ` [RFC 3/6] Lock the demangled hash table Tom Tromey
2019-03-09 17:23 ` [RFC 4/6] Introduce run_on_main_thread Tom Tromey
2019-03-09 17:23 ` [RFC 1/6] Defer minimal symbol name-setting Tom Tromey
2019-03-09 17:23 ` [RFC 5/6] Introduce thread-safe way to handle SIGSEGV Tom Tromey
2019-03-11 17:24   ` John Baldwin
2019-03-09 17:23 ` [RFC 2/6] Remove static buffer from ada_decode Tom Tromey
2019-03-09 18:09 ` [RFC 0/6] Demangle minimal symbol names in worker threads Eli Zaretskii
2019-03-11 17:35   ` John Baldwin
2019-03-11 22:39   ` Tom Tromey
2019-03-12  3:33     ` Eli Zaretskii
2019-03-13 15:38       ` Eli Zaretskii [this message]
2019-03-15 23:28         ` Tom Tromey
2019-03-16  7:46           ` Eli Zaretskii
2019-03-16  8:31             ` Eli Zaretskii
2019-03-15 23:40         ` Tom Tromey
2019-03-16  7:52           ` Eli Zaretskii
2019-03-11 17:26 ` John Baldwin
2019-03-11 22:40   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83muly3htw.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox