Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C++ 2011 threading read/write locking?

53 views
Skip to first unread message

blt_a...@h4gtm9uj3i5lygp_c2ioctrq.com

unread,
Mar 31, 2019, 4:53:50 AM3/31/19
to
Is there any equivalent of the pthreads pthread_rwlock_t in C++ threading?
shared_mutex seems to be mentioned but the functionality seems different to
me pluts its 2017 only anyway which rules out the compiler I'm using.

Melzzzzz

unread,
Mar 31, 2019, 5:27:45 AM3/31/19
to
Use pthread_rwlock_t, as you don't have c++17 compliant compiler.
What's difference between pthread and C++17 variant, just to start
discussion?

>


--
press any key to continue or any other to quit...

blt_...@rjrnwk17q3gki8i5ps4p50dlbz.org

unread,
Mar 31, 2019, 6:22:51 AM3/31/19
to
On Sun, 31 Mar 2019 09:27:34 GMT
Melzzzzz <Melz...@zzzzz.com> wrote:
>On 2019-03-31, blt_abadcf@h4gtm9uj3i5lygp_c2ioctrq.com
><blt_abadcf@h4gtm9uj3i5lygp_c2ioctrq.com> wrote:
>> Is there any equivalent of the pthreads pthread_rwlock_t in C++ threading?
>> shared_mutex seems to be mentioned but the functionality seems different to
>> me pluts its 2017 only anyway which rules out the compiler I'm using.
>
>Use pthread_rwlock_t, as you don't have c++17 compliant compiler.

Umm, because I was hoping to use C++ threading as its syntatically tidier
than pthreads and getting lambdas to work with pthreads would probably be a
PITA (I don't know, never tried).

Melzzzzz

unread,
Mar 31, 2019, 7:23:55 AM3/31/19
to
it's easy:
eg
#include <functional>
#include <stdio.h>
using std::function;
void f(void* lambda) {
function<void(int)>* pf = (function<void(int)>*)lambda;
(*pf)(5);
}

int main(){
int j = 5;
function<void(int)> l = [j](int){ printf("%d\n",j); };
f(&l);

Sam

unread,
Mar 31, 2019, 8:51:40 AM3/31/19
to
"Getting lambdas to work with pthreads", whatever that means, is no harder
and no easier than getting lambdas to work with anything else.

It shouldn't take more than an hour, or so, to write a C++ class wrapper
around pthread_rwlock_t that implements similar functionality to the C++17
class. It's not complicated. If you started when you posted your first
message in this thread, you would've probably been done by the time you
posted your second message in this thread.


blt_8...@1fcy52bz_kvxxu.net

unread,
Mar 31, 2019, 12:23:56 PM3/31/19
to
On Sun, 31 Mar 2019 08:51:29 -0400
Sam <s...@email-scan.com> wrote:
>This is a MIME GnuPG-signed message. If you see this text, it means that
>your E-mail or Usenet software does not support MIME signed messages.
>The Internet standard for MIME PGP messages, RFC 2015, was published in 1996.
>To open this message correctly you will need to install E-mail or Usenet
>software that supports modern Internet standards.
>
>--=_monster.email-scan.com-26718-1554036689-0001
>Content-Type: text/plain; format=flowed; delsp=yes; charset="UTF-8"
>Content-Disposition: inline
>Content-Transfer-Encoding: 7bit
>
>blt_...@rjrnwk17q3gki8i5ps4p50dlbz.org writes:
>
>> On Sun, 31 Mar 2019 09:27:34 GMT
>> Melzzzzz <Melz...@zzzzz.com> wrote:
>> >
>> >Use pthread_rwlock_t, as you don't have c++17 compliant compiler.
>>
>> Umm, because I was hoping to use C++ threading as its syntatically tidier
>> than pthreads and getting lambdas to work with pthreads would probably be a
>> PITA (I don't know, never tried).
>
>"Getting lambdas to work with pthreads", whatever that means, is no harder

I'll assume English is your second language if you didn't understand that.

>It shouldn't take more than an hour, or so, to write a C++ class wrapper
>around pthread_rwlock_t that implements similar functionality to the C++17
>class. It's not complicated. If you started when you posted your first
>message in this thread, you would've probably been done by the time you
>posted your second message in this thread.

I could write a class wrapper around pthreads? Wow! Why didn't I think of that??
Truly a savant and nobel prizes surely await you!

I guess trying to be a smart ass is more satisfying for you than just giving a
simple answer, right?

blt_c7...@x7o.gov

unread,
Mar 31, 2019, 12:25:10 PM3/31/19
to
On Sun, 31 Mar 2019 11:23:45 GMT
And what exactly is the point of using lambda functions if you have to write a
wrapper function for them anyway? You might just as well put the code in a
standard function.

Melzzzzz

unread,
Mar 31, 2019, 12:54:26 PM3/31/19
to
You said it is difficult. It is not.

blt_1...@cvjfc_s2lr2wbr2y.org

unread,
Mar 31, 2019, 1:12:42 PM3/31/19
to
On Sun, 31 Mar 2019 16:54:17 GMT
Any idiot can wrap a lambda, I meant passing one direct to pthread_create().
Show us your code for that.

Sam

unread,
Mar 31, 2019, 1:18:34 PM3/31/19
to
blt_8u6bgf6@1fcy52bz_kvxxu.net writes:

> On Sun, 31 Mar 2019 08:51:29 -0400
> Sam <s...@email-scan.com> wrote:
>
> >blt_...@rjrnwk17q3gki8i5ps4p50dlbz.org writes:
> >
> >> On Sun, 31 Mar 2019 09:27:34 GMT
> >> Melzzzzz <Melz...@zzzzz.com> wrote:
> >> >
> >> >Use pthread_rwlock_t, as you don't have c++17 compliant compiler.
> >>
> >> Umm, because I was hoping to use C++ threading as its syntatically tidier
> >> than pthreads and getting lambdas to work with pthreads would probably be
> a
> >> PITA (I don't know, never tried).
> >
> >"Getting lambdas to work with pthreads", whatever that means, is no harder
>
> I'll assume English is your second language if you didn't understand that.

You seem to be assuming a great deal many of things.

That, understandably, is often the only possible avenue when no other
options are available.

The statement "Getting lambdas to work with threads" is logically equivalent
to "making elephants fly with automobiles".

There's nothing unique about POSIX threads that requires employing any
unique aspects or attributes of lambdas. Or vice versa. Most fundamental
POSIX structures are not copyable; but that's not some earth-shattering
property either. Plenty of classes in the C++ library are also not copyable.
Like std::ifstream, for example. So the same issues, with regards to
captures, apply to POSIX threads as they do to std::ifstream, when it comes
to lambdas. There's nothing particularly special about POSIX threads and
lambdas.

So, your obsession with lambdas and POSIX threads is, pretty much, totally
unwarranted.

> >It shouldn't take more than an hour, or so, to write a C++ class wrapper
> >around pthread_rwlock_t that implements similar functionality to the C++17
> >class. It's not complicated. If you started when you posted your first
> >message in this thread, you would've probably been done by the time you
> >posted your second message in this thread.
>
> I could write a class wrapper around pthreads? Wow! Why didn't I think of
> that??

That's why I'm here, to help.

> Truly a savant and nobel prizes surely await you!

I'll decline. I don't like traveling.

> I guess trying to be a smart ass is more satisfying for you than just giving
> a
> simple answer, right?

I just did give a simple answer: write a simple wrapper. Can't get any
simpler than that.

Jorgen Grahn

unread,
Mar 31, 2019, 3:20:46 PM3/31/19
to
On Sun, 2019-03-31, blt_8u6bgf6@1fcy52bz_kvxxu.net wrote:
> On Sun, 31 Mar 2019 08:51:29 -0400
> Sam <s...@email-scan.com> wrote:
...
> I could write a class wrapper around pthreads? Wow! Why didn't I think of that??
> Truly a savant and nobel prizes surely await you!

Please: drop the sarcasm. Your original question was reasonable and
you obviously wanted an answer. It was even more interesting than
90% of the postings here.

At the same time, you /know/ you're now turning it into the same old
flamewar.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .

Chris M. Thomasson

unread,
Mar 31, 2019, 5:03:11 PM3/31/19
to
Fwiw, you just might be interested in the following thread:

https://groups.google.com/d/topic/comp.lang.c++/DBIG55vCBSA/discussion

Here is my crude C++ code:

https://pastebin.com/raw/1QtPCGhV

Melzzzzz

unread,
Mar 31, 2019, 11:15:08 PM3/31/19
to
So you are bellow level of idiot?

blt...@5c_mkufnilan750.co.uk

unread,
Apr 1, 2019, 5:24:42 AM4/1/19
to
On Sun, 31 Mar 2019 13:18:21 -0400
Sam <s...@email-scan.com> wrote:
>The statement "Getting lambdas to work with threads" is logically equivalent
>to "making elephants fly with automobiles".

Perhaps you should share your insights about that with the C++ steering
committee since they did exactlty that. Not sure how they're getting on
with the elephants however.

>> Truly a savant and nobel prizes surely await you!
>
>I'll decline. I don't like traveling.

I guess it can be scary coming out of your parents basement.

blt_fy...@3wg.ac.uk

unread,
Apr 1, 2019, 5:26:57 AM4/1/19
to
On 31 Mar 2019 19:20:34 GMT
Jorgen Grahn <grahn...@snipabacken.se> wrote:
>On Sun, 2019-03-31, blt_8u6bgf6@1fcy52bz_kvxxu.net wrote:
>> On Sun, 31 Mar 2019 08:51:29 -0400
>> Sam <s...@email-scan.com> wrote:
>....
>> I could write a class wrapper around pthreads? Wow! Why didn't I think of
>that??
>> Truly a savant and nobel prizes surely await you!
>
>Please: drop the sarcasm. Your original question was reasonable and
>you obviously wanted an answer. It was even more interesting than
>90% of the postings here.
>
>At the same time, you /know/ you're now turning it into the same old
>flamewar.

The older I get the less tolerant I am of idiot trolls on usenet.

blt_...@5nnj1zezih7uyebzv1zvpzlbp.gov

unread,
Apr 1, 2019, 5:30:52 AM4/1/19
to
On Mon, 01 Apr 2019 03:14:59 GMT
Bellow level? Is that where people shout a lot but don't actually say
anything useful? I'm sure you'd be right at home there.

David Brown

unread,
Apr 1, 2019, 6:10:32 AM4/1/19
to
Surely you are smart enough to figure out the best course of action. I
don't think you will be missed.

Sam

unread,
Apr 1, 2019, 6:57:45 AM4/1/19
to
blt_mm@5c_mkufnilan750.co.uk writes:

> On Sun, 31 Mar 2019 13:18:21 -0400
> Sam <s...@email-scan.com> wrote:
> >The statement "Getting lambdas to work with threads" is logically equivalent
> >to "making elephants fly with automobiles".
>
> Perhaps you should share your insights about that with the C++ steering
> committee since they did exactlty that. Not sure how they're getting on
> with the elephants however.

I doubt that you are capable of comprehending of what the C++ steering does
or doesn't do. It's obviously above your pay level.


Sam

unread,
Apr 1, 2019, 7:00:31 AM4/1/19
to
blt_fy...@3wg.ac.uk writes:

> The older I get the less tolerant I am of idiot trolls on usenet.

Metamucil is cheap.

blt_...@g7zdtja.org

unread,
Apr 1, 2019, 7:05:09 AM4/1/19
to
On Mon, 01 Apr 2019 07:00:22 -0400
Sam <s...@email-scan.com> wrote:
>This is a MIME GnuPG-signed message. If you see this text, it means that
>your E-mail or Usenet software does not support MIME signed messages.
>The Internet standard for MIME PGP messages, RFC 2015, was published in 1996.
>To open this message correctly you will need to install E-mail or Usenet
>software that supports modern Internet standards.
>
>--=_monster.email-scan.com-48885-1554116422-0002
>Content-Type: text/plain; format=flowed; delsp=yes; charset="UTF-8"
>Content-Disposition: inline
>Content-Transfer-Encoding: 7bit
>
>blt_fy...@3wg.ac.uk writes:
>
>> The older I get the less tolerant I am of idiot trolls on usenet.
>
>Metamucil is cheap.

So thats what you take. Explains why you post so much shit.

Sam

unread,
Apr 1, 2019, 8:33:32 AM4/1/19
to
You're just incapable of fully comprehending my greatness. Hence my
suggestion.

P.S. Happy birthday!

blt...@l9ghrtg9hdkmdxd43u9.net

unread,
Apr 1, 2019, 10:15:07 AM4/1/19
to
On Mon, 01 Apr 2019 08:33:23 -0400
Sam <s...@email-scan.com> wrote:
>This is a MIME GnuPG-signed message. If you see this text, it means that
>your E-mail or Usenet software does not support MIME signed messages.
>The Internet standard for MIME PGP messages, RFC 2015, was published in 1996.
>To open this message correctly you will need to install E-mail or Usenet
>software that supports modern Internet standards.
>
>--=_monster.email-scan.com-48885-1554122003-0003
>Content-Type: text/plain; format=flowed; delsp=yes; charset="UTF-8"
>Content-Disposition: inline
>Content-Transfer-Encoding: 7bit
>
Sadly my birthday is months away but April 1st is probably yours.

Sam

unread,
Apr 1, 2019, 2:30:24 PM4/1/19
to
Oh, sorry about that. I misread the date on your birth certificate. You were
definitely born yesterday.

Thank you, thank you! I'll be here all week. Try the buffet.

Chris M. Thomasson

unread,
Apr 1, 2019, 4:13:51 PM4/1/19
to
Jesus!

Sam

unread,
Apr 1, 2019, 6:04:34 PM4/1/19
to
No, I'm not him. But that was an understandable mistake.


Chris M. Thomasson

unread,
Apr 1, 2019, 11:45:32 PM4/1/19
to
Agreed. :)

Chris M. Thomasson

unread,
Apr 10, 2019, 4:43:35 PM4/10/19
to
Have you found the time to give this a go? :^)
0 new messages