c++ - spin_lock.h port from windows to linux -


i have following header:

#if !defined(_spin_lock_h_included_) #define _spin_lock_h_included_  #include <windows.h>  class spin_lock { public:     spin_lock();     virtual ~spin_lock();      void lock( void );     void unlock( void );  private:     critical_section m_lock;      spin_lock( const spin_lock& );     const spin_lock& operator = ( const spin_lock& ); }; 

there possibility port on linux minimum changes ?

after comment i'm getting error:

in file included ../sources/utils.11.0/mypdflibutils.cpp:43:0: ../sources/utils.11.0/spin_lock.h:39:2: error: ‘critical_section’ not name type critical_section m_lock;

critical_section declared in winbase.h part of microsoft sdk

this implementation:

#include <windows.h>  #include "spin_lock.h"  spin_lock::spin_lock() {     ::initializecriticalsection( &m_lock ); }  spin_lock::~spin_lock() {     ::deletecriticalsection( &m_lock ); }  void spin_lock::lock( void ) {     ::entercriticalsection( &m_lock ); }  void spin_lock:: unlock( void ) {     ::leavecriticalsection( &m_lock ); } 


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -