1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: src/gtk1/threadno.cpp 3 // Purpose: Solaris thread support 4 // Author: Guilhem Lavaux 5 // Modified by: 6 // Created: 04/22/98 7 // Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998) 8 // Licence: wxWindows licence 9 ///////////////////////////////////////////////////////////////////////////// 10 11 // For compilers that support precompilation, includes "wx.h". 12 #include "wx/wxprec.h" 13 14 #include "wx/thread.h" 15 16 #ifndef WX_PRECOMP 17 #include "wx/wx.h" 18 #include "wx/log.h" 19 #include "wx/module.h" 20 #endif 21 wxMutex()22wxMutex::wxMutex() 23 { 24 m_locked = 0; 25 } 26 ~wxMutex()27wxMutex::~wxMutex() 28 { 29 if (m_locked) 30 { 31 wxLogDebug( "wxMutex warning: destroying a locked mutex (%d locks)", m_locked ); 32 } 33 } 34 Lock()35wxMutexError wxMutex::Lock() 36 { 37 m_locked++; 38 return wxMUTEX_NO_ERROR; 39 } 40 TryLock()41wxMutexError wxMutex::TryLock() 42 { 43 if (m_locked > 0) 44 return wxMUTEX_BUSY; 45 m_locked++; 46 return wxMUTEX_NO_ERROR; 47 } 48 Unlock()49wxMutexError wxMutex::Unlock() 50 { 51 if (m_locked == 0) 52 return wxMUTEX_UNLOCKED; 53 m_locked--; 54 return wxMUTEX_NO_ERROR; 55 } 56 wxCondition()57wxCondition::wxCondition() 58 { 59 } 60 ~wxCondition()61wxCondition::~wxCondition() 62 { 63 } 64 Wait(wxMutex & WXUNUSED (mutex))65void wxCondition::Wait(wxMutex& WXUNUSED(mutex)) 66 { 67 } 68 Wait(wxMutex & WXUNUSED (mutex),unsigned long WXUNUSED (sec),unsigned long WXUNUSED (nsec))69bool wxCondition::Wait(wxMutex& WXUNUSED(mutex), unsigned long WXUNUSED(sec), 70 unsigned long WXUNUSED(nsec)) 71 { 72 return false; 73 } 74 Signal()75void wxCondition::Signal() 76 { 77 } 78 Broadcast()79void wxCondition::Broadcast() 80 { 81 } 82 83 struct wxThreadInternal 84 { 85 int thread_id; 86 void* exit_status; 87 }; 88 Create()89wxThreadError wxThread::Create() 90 { 91 p_internal->exit_status = Entry(); 92 OnExit(); 93 return wxTHREAD_NO_ERROR; 94 } 95 Destroy()96wxThreadError wxThread::Destroy() 97 { 98 return wxTHREAD_NOT_RUNNING; 99 } 100 Pause()101wxThreadError wxThread::Pause() 102 { 103 return wxTHREAD_NOT_RUNNING; 104 } 105 Resume()106wxThreadError wxThread::Resume() 107 { 108 return wxTHREAD_NOT_RUNNING; 109 } 110 DeferDestroy(bool WXUNUSED (on))111void wxThread::DeferDestroy( bool WXUNUSED(on) ) 112 { 113 } 114 TestDestroy()115void wxThread::TestDestroy() 116 { 117 } 118 Join()119void *wxThread::Join() 120 { 121 return p_internal->exit_status; 122 } 123 GetID() const124unsigned long wxThread::GetID() const 125 { 126 return 0; 127 } 128 IsMain()129bool wxThread::IsMain() 130 { 131 return true; 132 } 133 IsRunning() const134bool wxThread::IsRunning() const 135 { 136 return false; 137 } 138 IsAlive() const139bool wxThread::IsAlive() const 140 { 141 return false; 142 } 143 SetPriority(int WXUNUSED (prio))144void wxThread::SetPriority(int WXUNUSED(prio)) { } GetPriority() const145int wxThread::GetPriority() const { return 0; } 146 147 wxMutex *wxMainMutex; // controls access to all GUI functions 148 wxThread()149wxThread::wxThread() 150 { 151 p_internal = new wxThreadInternal(); 152 } 153 ~wxThread()154wxThread::~wxThread() 155 { 156 Destroy(); 157 Join(); 158 delete p_internal; 159 } 160 161 // The default callback just joins the thread and throws away the result. OnExit()162void wxThread::OnExit() 163 { 164 Join(); 165 } 166 IMPLEMENT_DYNAMIC_CLASS(wxThreadModule,wxModule)167IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule) 168 169 bool wxThreadModule::OnInit() 170 { 171 wxMainMutex = new wxMutex(); 172 wxMainMutex->Lock(); 173 return true; 174 } 175 OnExit()176void wxThreadModule::OnExit() 177 { 178 wxMainMutex->Unlock(); 179 delete wxMainMutex; 180 } 181 182 183 wxMutexGuiEnter()184void wxMutexGuiEnter() 185 { 186 } 187 wxMutexGuiLeave()188void wxMutexGuiLeave() 189 { 190 } 191