1 Replies - 641 Views - Last Post: 15 February 2012 - 02:35 AM Rate Topic: -----

#1 novacrazy  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 117
  • Joined: 01-March 11

printf losing thread-safety in C++0x/11, recommendations?

Posted 14 February 2012 - 10:54 PM

Without using the new standard on GCC, printf seemed to have good thread safety, no mangled output or anything. However, with the new standard, it seems to have lost that, and the output it complete mangled, as if it were unbuffered. So, I'm asking your opinion on what you'd recommend as far as what to do about it.

Should I ( a ), make a small wrapper around vprintf that includes either a basic mutex/spinlock,
or
should I ( b ), attempt to create a moderately thread-safe buffering system with that wrapper to allow for fast additions of requests that will be printed sequentially with one instance of vprintf? Or something like that. a thread-safe buffering system?

Or whatever else you'd suggest?

Mangled text kind of screws things up. Lol. However, I'm not quite sure what locking method is the fastest in pthread-win32, spinlocks actually seem to take longer... but, I'll run some tests, I suppose.

Any opinion would be greatly appreciated :)

This post has been edited by novacrazy: 14 February 2012 - 10:55 PM


Is This A Good Question/Topic? 0
  • +

Replies To: printf losing thread-safety in C++0x/11, recommendations?

#2 IngeniousHax  Icon User is offline

  • |>|20-514<|{3|2

Reputation: 78
  • View blog
  • Posts: 1,358
  • Joined: 28-March 09

Re: printf losing thread-safety in C++0x/11, recommendations?

Posted 15 February 2012 - 02:35 AM

Don't know if these references will help, but here are some things?
Secure Coding - strings

Multithreading with C++ and MFC
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1