Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7314 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Apr 17, 2006, 1:19:20 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: ShellBuffer is now ThreadSafe for printing to it
I must say: SDL_Thread's are way easier than simple pThreads

Location:
trunk/src/lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/shell/shell_buffer.cc

    r6222 r7314  
    4242
    4343ShellBuffer* ShellBuffer::singletonRef = NULL;
     44SDL_mutex* ShellBuffer::bufferMutex = NULL;
    4445
    4546/**
     
    5253
    5354  this->flush();
     55
     56  if (ShellBuffer::bufferMutex != NULL)
     57    SDL_DestroyMutex(ShellBuffer::bufferMutex);
     58  ShellBuffer::bufferMutex = NULL;
    5459
    5560  ShellBuffer::singletonRef = NULL;
     
    103108  va_start(arguments, line);
    104109
     110  if (ShellBuffer::bufferMutex == NULL)
     111    ShellBuffer::bufferMutex = SDL_CreateMutex();
     112
     113  SDL_mutexP(ShellBuffer::bufferMutex);
    105114#if DEBUG < 3
    106115  if (ShellBuffer::singletonRef == NULL)
    107116#endif
    108 
    109117    vprintf(line, arguments);
    110118#if DEBUG < 3
     
    114122#endif
    115123    ShellBuffer::singletonRef->addBufferLine(line, arguments);
     124  SDL_mutexV(ShellBuffer::bufferMutex);
    116125  return true;
    117126}
  • trunk/src/lib/shell/shell_buffer.h

    r5784 r7314  
    1010#include <stdarg.h>
    1111#include <list>
     12#include <SDL_thread.h>
    1213
    1314#define      SHELL_BUFFER_SIZE       16384         //!< The Size of the input-buffers (should be large enough to carry any kind of input)
     
    6061
    6162    unsigned long            lineCount;                          //!< how many Lines have been written out so far.
     63
     64    static SDL_mutex*        bufferMutex;                        //!< Only one thread may write into the ShellBuffer at a time.
    6265};
    6366
  • trunk/src/lib/sound/ogg_player.cc

    r7313 r7314  
    1313   co-programmer: ...
    1414
     15    Beware:
     16   The Ogg-Player is a __Threaded__ Stream, this means, that invoking play()
     17   creates a Thread, that loops through the Music-File. The Thread seems
     18   to be safe, but it is not guarantied.
    1519
    1620   -------------------------------------------------------------------
    17    The source of this file comes stright from http://www.devmaster.net
     21   A Simple Version of this can be found at http://www.devmaster.net
    1822   Thanks a lot for the nice work, and the easy portability to our Project.
    1923*/
    20 
    2124#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_SOUND
    2225
Note: See TracChangeset for help on using the changeset viewer.