#ifndef VCZH_THREADING
#define VCZH_THREADING
#include <Vlpp.h>
namespace
{
namespace
{
struct
;
struct
;
struct
;
struct
;
struct
;
struct
;
struct
;
struct
;
}
class
:
public
,
public
{
#if defined VCZH_MSVC
private
:
threading_internal
::
*
;
protected
:
();
void
(
threading_internal
::
*
);
public
:
bool
();
bool
();
bool
(
);
static
bool
(
**
,
);
static
bool
(
**
,
,
);
static
(
**
,
,
bool
*
);
static
(
**
,
,
,
bool
*
);
#elif defined VCZH_GCC
virtual bool Wait() = 0;
#endif
};
class
:
public
{
friend
void
(
*
);
public
:
enum
{
,
,
};
typedef
void
(*
)(
*,
void
*);
protected
:
threading_internal
::
*
;
volatile
;
virtual
void
()=
0
;
();
public
:
();
static
*
(
,
void
*
=
0
,
bool
=
true
);
static
*
(
const
<
void
()>&
,
bool
=
true
);
static
void
(
);
static
();
static
();
bool
();
#if defined VCZH_GCC
bool Wait();
#endif
bool
();
();
#ifdef VCZH_MSVC
void
(
);
#endif
};
class
:
public
{
private
:
threading_internal
::
*
;
public
:
();
();
bool
(
bool
=
false
,
const
&
=
L""
);
bool
(
bool
,
const
&
);
bool
();
#ifdef VCZH_GCC
bool Wait();
#endif
};
class
:
public
{
private
:
threading_internal
::
*
;
public
:
();
();
bool
(
,
,
const
&
=
L""
);
bool
(
bool
,
const
&
);
bool
();
(
);
#ifdef VCZH_GCC
bool Wait();
#endif
};
class
:
public
{
private
:
threading_internal
::
*
;
public
:
();
();
bool
(
bool
,
const
&
=
L""
);
bool
(
bool
,
const
&
=
L""
);
bool
(
bool
,
const
&
);
bool
();
bool
();
#ifdef VCZH_GCC
bool Wait();
#endif
};
class
:
public
{
private
:
();
();
public
:
static
bool
(
void
(*
)(
void
*),
void
*
);
static
bool
(
const
<
void
()>&
);
template
<
typename
>
static
void
(
const
&
)
{
(
<
void
()>(
));
}
#ifdef VCZH_GCC
static bool Stop(bool discardPendingTasks);
#endif
};
class
:
public
,
public
{
private
:
friend
class
;
threading_internal
::
*
;
public
:
();
();
bool
();
void
();
void
();
public
:
class
:
public
,
public
{
private
:
*
;
public
:
(
&
);
();
};
};
class
:
public
,
public
{
private
:
friend
class
;
threading_internal
::
*
;
public
:
();
();
bool
();
void
();
void
();
bool
();
void
();
void
();
public
:
class
:
public
,
public
{
private
:
*
;
public
:
(
&
);
();
};
class
:
public
,
public
{
private
:
*
;
public
:
(
&
);
();
};
};
class
:
public
,
public
{
private
:
threading_internal
::
*
;
public
:
();
();
bool
(
&
);
#ifdef VCZH_MSVC
bool
(
&
,
);
bool
(
&
);
bool
(
&
,
);
bool
(
&
);
bool
(
&
,
);
#endif
void
();
void
();
};
typedef
long
;
class
:
public
,
public
{
protected
:
volatile
;
public
:
();
();
bool
();
void
();
void
();
public
:
class
:
public
,
public
{
private
:
*
;
public
:
(
&
);
();
};
};
#define SPIN_LOCK(LOCK) SCOPE_VARIABLE(const SpinLock::Scope&, scope, LOCK)
#define CS_LOCK(LOCK) SCOPE_VARIABLE(const CriticalSection::Scope&, scope, LOCK)
#define READER_LOCK(LOCK) SCOPE_VARIABLE(const ReaderWriterLock::ReaderScope&, scope, LOCK)
#define WRITER_LOCK(LOCK) SCOPE_VARIABLE(const ReaderWriterLock::WriterScope&, scope, LOCK)
class
:
public
,
private
{
typedef
void
(*
)(
void
*);
protected
:
;
;
volatile
bool
=
false
;
static
void
(
*
);
public
:
(
);
();
void
*
();
void
(
void
*
);
void
();
void
();
static
void
();
static
void
();
static
void
();
};
template
<
typename
>
class
:
public
,
private
{
protected
:
;
static
void
(
void
*
)
{
if
(
)
{
delete
(
*)
;
}
}
public
:
()
:storage(&
)
{
}
()
{
}
bool
()
{
return
.
() !=
nullptr
;
}
void
()
{
.
();
}
&
()
{
return
*(
*)
.
();
}
void
(
const
&
)
{
.
();
.
(
new
(
));
}
};
template
<
typename
>
class
<
*> :
public
,
private
{
protected
:
;
public
:
()
:storage(
nullptr
)
{
}
()
{
}
bool
()
{
return
.
() !=
nullptr
;
}
void
()
{
.
(
nullptr
);
}
*
()
{
return
(
*)
.
();
}
void
(
*
)
{
.
((
void
*)
);
}
};
template
<
typename
>
class
:
public
{
private
:
;
;
volatile
bool
;
;
volatile
bool
;
void
()
{
while
(
true
)
{
bool
;
;
SPIN_LOCK(inputLock)
if
(
bool
=
true
)
for
(
const
::
&
=
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
currentInputData
=
;
=
();
currentInputDataAvailable
=
;
=
false
;
if
(!
currentInputDataAvailable
)
{
=
false
;
goto
FINISH_EXECUTING;
}
}
(
currentInputData
);
}
FINISH_EXECUTING:
.
();
}
static
void
(
void
*
)
{
((
<
>*)
)->
();
}
protected
:
virtual
void
(
const
&
)=
0
;
public
:
()
:inputDataAvailable(
false
)
,executing(
false
)
{
}
()
{
();
}
void
()
{
.
();
.
();
}
void
(
const
&
)
{
SPIN_LOCK(inputLock)
if
(
bool
=
true
)
for
(
const
::
&
=
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
=
;
=
true
;
}
if
(!
)
{
=
true
;
.
();
::
(&
,
this
);
}
}
};
}
#endif