| 1 |
#ifndef TinyJS_Threading_h__ |
| 2 |
#define TinyJS_Threading_h__ |
| 3 |
#include "config.h" |
| 4 |
#ifndef NO_THREADING |
| 5 |
/* |
| 6 |
* 42TinyJS |
| 7 |
* |
| 8 |
* A fork of TinyJS with the goal to makes a more JavaScript/ECMA compliant engine |
| 9 |
* |
| 10 |
* Authored By Armin Diedering <armin@diedering.de> |
| 11 |
* |
| 12 |
* Copyright (C) 2010-2013 ardisoft |
| 13 |
* |
| 14 |
* |
| 15 |
* Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 16 |
* this software and associated documentation files (the "Software"), to deal in |
| 17 |
* the Software without restriction, including without limitation the rights to |
| 18 |
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
| 19 |
* of the Software, and to permit persons to whom the Software is furnished to do |
| 20 |
* so, subject to the following conditions: |
| 21 |
|
| 22 |
* The above copyright notice and this permission notice shall be included in all |
| 23 |
* copies or substantial portions of the Software. |
| 24 |
|
| 25 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 26 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 27 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 28 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 29 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 30 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 31 |
* SOFTWARE. |
| 32 |
*/ |
| 33 |
|
| 34 |
class CScriptMutex { |
| 35 |
public: |
| 36 |
CScriptMutex(); |
| 37 |
~CScriptMutex(); |
| 38 |
void lock() { mutex->lock(); } |
| 39 |
void unlock() { mutex->unlock(); } |
| 40 |
class CScriptMutex_t{ |
| 41 |
public: |
| 42 |
// virtual ~CScriptMutex_t()=0; |
| 43 |
virtual void lock()=0; |
| 44 |
virtual void unlock()=0; |
| 45 |
}; |
| 46 |
private: |
| 47 |
CScriptMutex_t *mutex; |
| 48 |
|
| 49 |
}; |
| 50 |
|
| 51 |
class CScriptThread { |
| 52 |
public: |
| 53 |
CScriptThread(); |
| 54 |
virtual ~CScriptThread(); |
| 55 |
void Run() { thread->Run(); } |
| 56 |
int Stop() { return thread->Stop(); } |
| 57 |
virtual int ThreadFnc()=0; |
| 58 |
bool isActiv() { return thread->isActiv(); } |
| 59 |
class CScriptThread_t{ |
| 60 |
public: |
| 61 |
virtual void Run()=0; |
| 62 |
virtual int Stop()=0; |
| 63 |
virtual bool isActiv()=0; |
| 64 |
}; |
| 65 |
private: |
| 66 |
CScriptThread_t *thread; |
| 67 |
}; |
| 68 |
|
| 69 |
#endif // NO_THREADING |
| 70 |
#endif // TinyJS_Threading_h__ |