Thread: opencv thread safe?

  1. #1
    Alessio Stella
    Join Date
    May 2008
    Location
    Italy, Bologna
    Posts
    251

    opencv thread safe?

    I still have to figure out:
    which openCV functions are pthread-safe?!

    By pthread-safe I mean that
    (1) opencv functions can be called by different threads on different
    data with no unexpected result, with no need of mutex protection. This
    imply opencv functions are fully reentrant (using only stack variables)
    (2) opencv functions can be called by different threads on the same
    data provided the ordinary use of pthread_mutex_lock()/trylock()/unlock
    ()/etc.

    A specific example: what to do if I wanna call cvGetTickCount() by
    different threads? Do I have to use mutexes??!! (that would spoil the
    measure)

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    Doesn't the manual page tell you?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Alessio Stella
    Join Date
    May 2008
    Location
    Italy, Bologna
    Posts
    251
    Quote Originally Posted by Salem View Post
    Doesn't the manual page tell you?
    strangely enough I do not think it does

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    In the absense of
    a) the manual telling you that it's thread safe
    b) you reading the source code to determine if it's thread safe,

    Then it's best to assume that it isn't thread safe at all.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. thread safe in Dispose method
    By George2 in forum C# Programming
    Replies: 3
    Last Post: 05-15-2008, 07:32 AM
  2. thread safe in my code to manipulate List?
    By George2 in forum C# Programming
    Replies: 8
    Last Post: 05-01-2008, 06:57 AM
  3. are winsock functions thread safe?
    By *DEAD* in forum Networking/Device Communication
    Replies: 2
    Last Post: 12-15-2007, 10:37 AM
  4. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  5. C++ Threading?
    By draggy in forum C++ Programming
    Replies: 5
    Last Post: 08-16-2005, 12:16 PM