Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Trylock for mutex  (Read 2383 times)

0 Members and 1 Guest are viewing this topic.

PhilJones

  • Newbie
  • *
  • Posts: 3
    • View Profile
Trylock for mutex
« on: April 21, 2011, 03:05:23 pm »
As subject, a non blocking trylock for the mutex similar to pthread_mutex_trylock.

Phil

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Trylock for mutex
« Reply #1 on: April 21, 2011, 03:27:27 pm »
Why?

I'm working with mutexes everyday and I've never needed this function.
Laurent Gomila - SFML developer

PhilJones

  • Newbie
  • *
  • Posts: 3
    • View Profile
Trylock for mutex
« Reply #2 on: April 21, 2011, 05:04:44 pm »
For a piece of performance critical code that continues to execute rather than wait for lock, and then locks later. Do you use something else, or have you never needed to worry about this?

Phil

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Trylock for mutex
« Reply #3 on: April 21, 2011, 05:52:24 pm »
I never needed this, if the piece of code can continue without locking why would it try to do it?

For performance critical code I personnally often use spinlocks.

Anyway, like I always say, SFML is not meant to be a complete threading library, it only provides the most basic things. If you're doing serious threading then you'd better choose a dedicated library.
Laurent Gomila - SFML developer

PhilJones

  • Newbie
  • *
  • Posts: 3
    • View Profile
Trylock for mutex
« Reply #4 on: April 21, 2011, 06:17:32 pm »
Fair enough, will do.

 

anything