#include "WfLibraryPredefined.h"
namespace
{
using
namespace
collections
;
namespace
{
namespace
{
::
()
{
return
;
}
void
::
(
const
&
)
{
;
}
<
>
::
()
{
return
;
}
void
::
(
<
>
)
{
;
}
class
:
public
,
public
virtual
::
,
public
<
>
{
protected
:
::
;
<
>
;
;
= -
1
;
<
>
;
public
:
(
const
::
&
)
:creator(
)
{
}
()
override
{
return
;
}
()
override
{
return
;
}
bool
()
override
{
if
(!
)
{
this
);
}
while
(
() ==
::
)
{
if
(
)
{
if
(
())
{
();
++;
return
true
;
}
else
{
nullptr
;
}
}
(
true
,
nullptr
);
if
(
() !=
::
)
{
break
;
}
if
(!
)
{
++;
return
true
;
}
}
return
false
;
}
void
(
const
&
)
override
{
;
nullptr
;
}
void
(
<
>
)
override
{
if
(!
)
{
throw
(
L"Cannot join a null collection."
);
}
();
();
}
};
class
:
public
,
public
virtual
,
public
<
>
{
protected
:
::
;
public
:
(
const
::
&
)
:creator(
)
{
}
<
>
()
override
{
return
new
(
);
}
};
void
::
(
*
,
const
&
)
{
->
(
);
}
void
::
(
*
,
<
>
)
{
->
(
);
}
void
::
(
*
)
{
}
<
>
::
(
const
&
)
{
return
new
(
);
}
::
(
const
&
)
:context(
)
{
}
::
()
{
}
bool
::
()
{
SPIN_LOCK(lock)
if
(
bool
=
true
)
for
(
const
::
&
=
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
return
;
}
CHECK_FAIL(L"Not reachable");
do
{
throw
(
L"Not reachable"
);}
while
(
0
);
}
bool
::
()
{
SPIN_LOCK(lock)
if
(
bool
=
true
)
for
(
const
::
&
=
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
if
(
)
return
false
;
=
true
;
return
true
;
}
CHECK_FAIL(L"Not reachable");
do
{
throw
(
L"Not reachable"
);}
while
(
0
);
}
const
description
::
&
::
()
{
SPIN_LOCK(lock)
if
(
bool
=
true
)
for
(
const
::
&
=
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
return
;
}
CHECK_FAIL(L"Not reachable");
do
{
throw
(
L"Not reachable"
);}
while
(
0
);
}
void
::
(
const
description
::
&
)
{
SPIN_LOCK(lock)
if
(
bool
=
true
)
for
(
const
::
&
=
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
;
}
}
class
:
public
,
public
virtual
,
public
<
>
{
protected
:
;
;
=
::
;
public
:
(
)
:milliseconds(
)
{
}
()
override
{
return
;
}
bool
(
const
<
void
(
<
>)>&
,
<
>
)
override
{
SPIN_LOCK(lock)
if
(
bool
=
true
)
for
(
const
::
&
=
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
if
(
!=
::
)
return
false
;
=
::
;
::
GetSchedulerForCurrentThread
()
([
=
<
>(
this
),
=
]()
{
if
(
callback
)
{
callback
nullptr
);
}
},
);
}
return
true
;
}
};
<
>
::
(
)
{
return
new
(
);
}
class
:
public
virtual
,
public
virtual
,
public
<
>
{
public
:
;
=
::
;
<
>
;
<
void
(
<
>)>
;
void
()
{
=
::
;
if
(
)
{
);
}
nullptr
;
{};
}
template
<
typename
>
bool
(
)
{
SPIN_LOCK(lock)
if
(
bool
=
true
)
for
(
const
::
&
=
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
if
(
==
::
||
)
return
false
;
<
>();
();
if
(
==
::
)
{
();
}
}
return
true
;
}
()
override
{
return
;
}
bool
(
const
<
void
(
<
>)>&
,
<
>
)
override
{
SPIN_LOCK(lock)
if
(
bool
=
true
)
for
(
const
::
&
=
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
if
(
!=
::
)
return
false
;
;
if
(
)
{
();
}
else
{
=
::
;
}
}
return
true
;
}
<
>
()
override
{
return
this
;
}
bool
(
const
&
)
override
{
return
([=]()
{
(
);
});
}
bool
(
<
>
)
override
{
return
([=]()
{
(
);
});
}
};
<
>
::
()
{
return
new
();
}
class
{
public
:
<
,
<
>>
;
<
>
;
};
*
=
nullptr
;
;
#define ENSURE_ASYNC_SCHEDULER_MAP\
if (!asyncSchedulerMap) asyncSchedulerMap = new AsyncSchedulerMap;
#define DISPOSE_ASYNC_SCHEDULER_MAP_IF_NECESSARY\
if (asyncSchedulerMap->schedulers.Count() == 0 && !asyncSchedulerMap->defaultScheduler)\
{\
delete asyncSchedulerMap;\
asyncSchedulerMap = nullptr;\
}\
void
::
(
<
>
)
{
SPIN_LOCK(asyncSchedulerLock)
if
(
bool
=
true
)
for
(
const
::
&
=
asyncSchedulerLock
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
ENSURE_ASYNC_SCHEDULER_MAP
if
(!
asyncSchedulerMap
)
asyncSchedulerMap
=
new
;
CHECK_ERROR(!asyncSchedulerMap->defaultScheduler, L"IAsyncScheduler::RegisterDefaultScheduler()#A default scheduler has already been registered.");
do
{
if
(!(!
asyncSchedulerMap
->
))
throw
(
L"IAsyncScheduler::RegisterDefaultScheduler()#A default scheduler has already been registered."
);}
while
(
0
);
asyncSchedulerMap
->
;
}
}
void
::
RegisterSchedulerForCurrentThread
(
<
>
)
{
SPIN_LOCK(asyncSchedulerLock)
if
(
bool
=
true
)
for
(
const
::
&
=
asyncSchedulerLock
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
ENSURE_ASYNC_SCHEDULER_MAP
if
(!
asyncSchedulerMap
)
asyncSchedulerMap
=
new
;
CHECK_ERROR(!asyncSchedulerMap->schedulers.Keys().Contains(Thread::GetCurrentThreadId()), L"IAsyncScheduler::RegisterDefaultScheduler()#A scheduler for this thread has already been registered.");
do
{
if
(!(!
asyncSchedulerMap
->
.
().
(
::
())))
throw
(
L"IAsyncScheduler::RegisterDefaultScheduler()#A scheduler for this thread has already been registered."
);}
while
(
0
);
asyncSchedulerMap
->
.
(
::
(),
);
}
}
<
>
::
UnregisterDefaultScheduler
()
{
<
>
;
SPIN_LOCK(asyncSchedulerLock)
if
(
bool
=
true
)
for
(
const
::
&
=
asyncSchedulerLock
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
if
(
asyncSchedulerMap
)
{
scheduler
asyncSchedulerMap
->
;
asyncSchedulerMap
->
nullptr
;
DISPOSE_ASYNC_SCHEDULER_MAP_IF_NECESSARY
if
(
asyncSchedulerMap
->
.
() ==
0
&& !
asyncSchedulerMap
->
) {
delete
asyncSchedulerMap
;
asyncSchedulerMap
=
nullptr
; }
}
}
return
scheduler
;
}
<
>
::
UnregisterSchedulerForCurrentThread
()
{
<
>
;
SPIN_LOCK(asyncSchedulerLock)
if
(
bool
=
true
)
for
(
const
::
&
=
asyncSchedulerLock
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
if
(
asyncSchedulerMap
)
{
=
asyncSchedulerMap
->
.
().
(
::
());
if
(
index
!= -
1
)
{
scheduler
asyncSchedulerMap
->
.
()
index
];
asyncSchedulerMap
->
.
(
::
());
}
DISPOSE_ASYNC_SCHEDULER_MAP_IF_NECESSARY
if
(
asyncSchedulerMap
->
.
() ==
0
&& !
asyncSchedulerMap
->
) {
delete
asyncSchedulerMap
;
asyncSchedulerMap
=
nullptr
; }
}
}
return
scheduler
;
}
#undef ENSURE_ASYNC_SCHEDULER_MAP
#undef DISPOSE_ASYNC_SCHEDULER_MAP_IF_NECESSARY
<
>
::
GetSchedulerForCurrentThread
()
{
<
>
;
SPIN_LOCK(asyncSchedulerLock)
if
(
bool
=
true
)
for
(
const
::
&
=
asyncSchedulerLock
;
__scope_variable_flag__
;
__scope_variable_flag__
=
false
)
{
CHECK_ERROR(asyncSchedulerMap != nullptr, L"IAsyncScheduler::GetSchedulerForCurrentThread()#There is no scheduler registered for the current thread.");
do
{
if
(!(
asyncSchedulerMap
!=
nullptr
))
throw
(
L"IAsyncScheduler::GetSchedulerForCurrentThread()#There is no scheduler registered for the current thread."
);}
while
(
0
);
=
asyncSchedulerMap
->
.
().
(
::
());
if
(
index
!= -
1
)
{
scheduler
asyncSchedulerMap
->
.
()
index
];
}
else
if
(
asyncSchedulerMap
->
)
{
scheduler
asyncSchedulerMap
->
;
}
else
{
CHECK_FAIL(L"IAsyncScheduler::GetSchedulerForCurrentThread()#There is no scheduler registered for the current thread.");
do
{
throw
(
L"IAsyncScheduler::GetSchedulerForCurrentThread()#There is no scheduler registered for the current thread."
);}
while
(
0
);
}
}
return
scheduler
;
}
class
:
public
,
public
virtual
::
,
public
<
>
{
protected
:
<
>
;
::
;
<
>
;
<
void
(
<
>)>
;
<
>
;
;
public
:
(
::
)
:creator(
)
{
}
()
override
{
if
(!
)
{
return
::
;
}
else
if
(
() !=
::
)
{
return
::
;
}
else
{
return
::
;
}
}
bool
(
const
<
void
(
<
>)>&
,
<
>
)
override
{
if
(
)
return
false
;
::
GetSchedulerForCurrentThread
();
;
;
this
);
(
nullptr
);
return
true
;
}
<
>
()
override
{
return
;
}
<
>
()
override
{
if
(!
)
{
new
;
}
return
;
}
void
(
<
>
)
override
{
([
=
<
>(
this
), output]()
{
async
(
false
,
);
if
(
async
() ==
::
&&
async
)
{
auto
=
<
>();
if
(
async
())
{
result
(
async
());
}
else
{
result
(
async
);
}
async
result
);
}
});
}
void
(
const
&
)
override
{
;
}
};
void
::
(
*
,
<
>
)
{
([
=
<
>(
)](
auto
)
{
async
(
output
);
},
->
());
}
void
::
(
*
,
const
&
)
{
->
(
);
}
<
>
::
(
*
)
{
return
->
();
}
<
>
::
(
const
&
)
{
return
new
(
);
}
void
::
(
const
&
)
{
<
>(
)
(
[](
<
>
)
{
if
(
cr
())
{
#pragma push_macro("GetMessage")
#if defined GetMessage
#undef GetMessage
#endif
throw
(
cr
()
());
#pragma pop_macro("GetMessage")
}
},
nullptr
);
}
void
::
()
{
<
>
;
while
(
true
)
{
if
(
nullptr
)
{
if
(!
)
{
throw
(
L"The state machine has not been initialized."
);
}
if
(
)
{
throw
(
L"The state machine has been stopped."
);
}
=
true
;
if
(
previousResult
)
{
if
(
auto
=
previousResult
())
{
throw Exception(failure->GetMessage());
throw
(
failure
GetMessageW());
}
}
break
;
}
else
if
(
() !=
::
)
{
auto
=
;
currentCoroutine
(
false
,
previousResult
);
if
(
currentCoroutine
)
{
break
;
}
else
if
(
currentCoroutine
() ==
::
)
{
previousResult
<
>();
if
(
auto
=
currentCoroutine
())
{
previousResult
(
failure
);
}
}
else
{
}
}
}
}
::
()
{
}
::
()
{
();
}
::
()
{
if
(
)
{
return
::
;
}
else
if
(
)
{
if
(
() ==
::
)
{
return
::
;
}
else
{
return
::
;
}
}
else
{
return
::
;
}
}
namespace
{
class
:
public
,
public
{
protected
:
<
>
;
class
:
public
,
public
{
protected
:
<
>
;
;
public
:
(
<
>
)
:list(
), index(
())
{
}
()
{
return
(
);
}
()
{
return
() -
1
-
;
}
bool
()
{
if
(
<=
0
)
return
false
;
--;
return
true
;
}
};
public
:
(
<
>
)
:list(
)
{
}
<
>
()
override
{
return
<
>(
);
}
};
}
::
()
{
return
::
();
}
::
()
{
return
::
();
}
::
(
)
{
return
.
();
}
::
(
)
{
return
.
();
}
::
(
,
)
{
return
.
(
);
}
::
(
,
)
{
return
.
(
);
}
::
(
,
,
)
{
return
::
(
,
,
);
}
::
(
,
,
,
,
,
,
)
{
return
::
(
,
,
,
,
,
,
);
}
::
(
)
{
return
::
(
);
}
<
>
::
(
<
>
)
{
auto
=
.
<
>();
if
(!
list
)
{
list
::
(
<
>(
));
}
return
new
system_sys
::
(
list
);
}
#define DEFINE_COMPARE(TYPE)\
vint Sys::Compare(TYPE a, TYPE b)\
{\
auto result = TypedValueSerializerProvider<TYPE>::Compare(a, b);\
switch (result)\
{\
case IBoxedValue::Smaller: return -1;\
case IBoxedValue::Greater: return 1;\
case IBoxedValue::Equal: return 0;\
default:\
CHECK_FAIL(L"Unexpected compare result.");\
}\
}\
REFLECTION_PREDEFINED_PRIMITIVE_TYPES(DEFINE_COMPARE)
::
(
,
) {
auto
=
TypedValueSerializerProvider
<
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
::
(
,
) {
auto
=
TypedValueSerializerProvider
<
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
::
(
,
) {
auto
=
TypedValueSerializerProvider
<
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
::
(
,
) {
auto
=
TypedValueSerializerProvider
<
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
::
(
,
) {
auto
=
TypedValueSerializerProvider
<
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
::
(
,
) {
auto
=
TypedValueSerializerProvider
<
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
::
(
,
) {
auto
=
TypedValueSerializerProvider
<
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
::
(
,
) {
auto
=
TypedValueSerializerProvider
<
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
::
(
float
,
float
) {
auto
=
TypedValueSerializerProvider
<
float
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
::
(
double
,
double
) {
auto
=
TypedValueSerializerProvider
<
double
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
::
(
bool
,
bool
) {
auto
=
TypedValueSerializerProvider
<
bool
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
::
(
wchar_t
,
wchar_t
) {
auto
=
TypedValueSerializerProvider
<
wchar_t
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
::
(
,
) {
auto
=
TypedValueSerializerProvider
<
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
::
(
,
) {
auto
=
TypedValueSerializerProvider
<
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
DEFINE_COMPARE(DateTime)
::
(
,
) {
auto
=
TypedValueSerializerProvider
<
>::
(
,
);
switch
(
result
) {
case
::
:
return
-
1
;
case
::
:
return
1
;
case
::
:
return
0
;
default
:
do
{
throw
(
L"Unexpected compare result."
);}
while
(
0
); } }
#undef DEFINE_COMPARE
#define DEFINE_MINMAX(TYPE)\
TYPE Math::Min(TYPE a, TYPE b)\
{\
return Sys::Compare(a, b) < 0 ? a : b;\
}\
TYPE Math::Max(TYPE a, TYPE b)\
{\
return Sys::Compare(a, b) > 0 ? a : b;\
}\
REFLECTION_PREDEFINED_PRIMITIVE_TYPES(DEFINE_MINMAX)
::
(
,
) {
return
::
(
,
) <
0
?
:
; }
::
(
,
) {
return
::
(
,
) >
0
?
:
; }
::
(
,
) {
return
::
(
,
) <
0
?
:
; }
::
(
,
) {
return
::
(
,
) >
0
?
:
; }
::
(
,
) {
return
::
(
,
) <
0
?
:
; }
::
(
,
) {
return
::
(
,
) >
0
?
:
; }
::
(
,
) {
return
::
(
,
) <
0
?
:
; }
::
(
,
) {
return
::
(
,
) >
0
?
:
; }
::
(
,
) {
return
::
(
,
) <
0
?
:
; }
::
(
,
) {
return
::
(
,
) >
0
?
:
; }
::
(
,
) {
return
::
(
,
) <
0
?
:
; }
::
(
,
) {
return
::
(
,
) >
0
?
:
; }
::
(
,
) {
return
::
(
,
) <
0
?
:
; }
::
(
,
) {
return
::
(
,
) >
0
?
:
; }
::
(
,
) {
return
::
(
,
) <
0
?
:
; }
::
(
,
) {
return
::
(
,
) >
0
?
:
; }
float
::
(
float
,
float
) {
return
::
(
,
) <
0
?
:
; }
float
::
(
float
,
float
) {
return
::
(
,
) >
0
?
:
; }
double
::
(
double
,
double
) {
return
::
(
,
) <
0
?
:
; }
double
::
(
double
,
double
) {
return
::
(
,
) >
0
?
:
; }
bool
::
(
bool
,
bool
) {
return
::
(
,
) <
0
?
:
; }
bool
::
(
bool
,
bool
) {
return
::
(
,
) >
0
?
:
; }
wchar_t
::
(
wchar_t
,
wchar_t
) {
return
::
(
,
) <
0
?
:
; }
wchar_t
::
(
wchar_t
,
wchar_t
) {
return
::
(
,
) >
0
?
:
; }
::
(
,
) {
return
::
(
,
) <
0
?
:
; }
::
(
,
) {
return
::
(
,
) >
0
?
:
; }
::
(
,
) {
return
::
(
,
) <
0
?
:
; }
::
(
,
) {
return
::
(
,
) >
0
?
:
; }
DEFINE_MINMAX(DateTime)
::
(
,
) {
return
::
(
,
) <
0
?
:
; }
::
(
,
) {
return
::
(
,
) >
0
?
:
; }
#undef DEFINE_MINMAX
::
()
{
return
::
();
}
::
()
{
return
::
();
}
::
()
{
return
::
();
}
collections
::
<
>
::
()
{
auto
=
<
<
>>();
::
(*
result
.
());
return
result
;
}
collections
::
<
>
::
(
)
{
auto
=
<
<
>>();
.
(*
result
.
());
return
result
;
}
collections
::
<
>
::
(
)
{
auto
=
<
<
>>();
.
(*
result
.
());
return
result
;
}
collections
::
<
>
::
(
)
{
auto
=
<
<
>>();
.
(*
result
.
());
return
result
;
}
collections
::
<
>
::
(
)
{
auto
=
<
<
>>();
.
(*
result
.
());
return
result
;
}
collections
::
<
>
::
(
)
{
auto
=
<
<
>>();
.
(*
result
.
());
return
result
;
}
::
(
,
)
{
return
.
(
);
}
::
(
,
)
{
return
.
(
);
}
::
(
,
)
{
return
.
(
);
}
::
(
,
)
{
return
.
(
);
}
::
(
,
const
&
,
)
{
return
.
(
,
);
}
::
(
,
const
&
,
)
{
return
.
(
,
);
}
::
(
,
const
&
)
{
return
.
(
);
}
::
(
,
const
&
)
{
return
.
(
);
}
}
}
}