Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Are std::list std::vector std::map thread-safe class?

Are std::list std::vector std::map thread-safe class?

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fantasy1215
    wrote on last edited by
    #1

    Two thread access a std::list object, either of two will add to/(delete) the std::list. When make critical section or mutex guard, I know can make the std::list safe. But does std::list itself implemented thread-safe? Thanks advanced for helping unlock my mind!

    L 1 Reply Last reply
    0
    • F fantasy1215

      Two thread access a std::list object, either of two will add to/(delete) the std::list. When make critical section or mutex guard, I know can make the std::list safe. But does std::list itself implemented thread-safe? Thanks advanced for helping unlock my mind!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You failed to mention which implementation of STL you are using as there are several available. These include SGI-STL, STLPort, Dinkumware and other minor vendors. There are some slight differences in how each handle concurrency. With that being said, the C++ standards do not make any guarantees about thread safety with iterator reading/writing to std::list from multiple threads. This essentially means that it is up to the software engineer to ensure thread-safety. Best Wishes, -David Delaune

      F 1 Reply Last reply
      0
      • L Lost User

        You failed to mention which implementation of STL you are using as there are several available. These include SGI-STL, STLPort, Dinkumware and other minor vendors. There are some slight differences in how each handle concurrency. With that being said, the C++ standards do not make any guarantees about thread safety with iterator reading/writing to std::list from multiple threads. This essentially means that it is up to the software engineer to ensure thread-safety. Best Wishes, -David Delaune

        F Offline
        F Offline
        fantasy1215
        wrote on last edited by
        #3

        Really thank you. You do me a big favor!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups