J Reece Wilson
fd0c5b51b2
[+] Begin work on IO futexes for io release on process/thread exit [+] Linux ::readdir iteration [+] AuConsole buffering API [*] Fix sleep as to not get interrupted by signals [*] Switch the type of FS lock used under Linux [*] Linux: Use new IPCHandle encoding scheme [*] Fix undefined behaviour: unintialized timeout values (AuLoop/Linux) [*] Fix undefined behaviour: ConsoleTTY clear line was called of a color of a random value on stack [-] Remainings of std dir iterator [*] Fix pthread_kill (aka send signal to pthread handle) always kills process. This is what you expect bc signal handler inheritance. [*] Reformat the build Aurora.json file [+] Added clang warning ignores to the build file [*] Fix: UNIX need to use STDOUT_FILENO. Was using CRT handle in place of fd by mistake. [+] Linux implementation for IO yield (AuIO::IOYield() - UNIX::LinuxOverlappedYield()) [*] Fix: Linux async end of stream processing. res 0 = zero bytes consumed. <= was detecting this as an error of code 0. Should succeed with zero bytes. [+] Linux LoopQueue missing epilogue hook for the IO processor [*] Various refactors and minor bug fixes [*] Linux fix: Handle pipe EOS as zero [*] Linux fix: thread termination via a user signal of 77. Need a force terminate. [*] IPC handle: fix improper int to bool cast in the header setup within ToString [*] Linux fix: HWInfo CPU topology regression [-] Linux fix: remove SIGABRT handler [*] Missing override in compression, exit, and consoletty headers. [+] Unix Syslog logger backend
184 lines
6.6 KiB
C++
184 lines
6.6 KiB
C++
/***
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: JobFrom.hpp
|
|
Date: 2021-11-1
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
namespace Aurora::Async
|
|
{
|
|
template<class Info_t = AVoid, class Result_t = AVoid, class Callable_t>
|
|
static inline FJob<Info_t, Result_t> JobFromPairConsumer(const /*AuConsumer<const Info_t &, const Result_t &> */ Callable_t&onSuccess)
|
|
{
|
|
FJob<Info_t, Result_t> ret;
|
|
ret.onSuccess = [=](const Info_t &in, const Result_t &a)
|
|
{
|
|
onSuccess(in, a);
|
|
};
|
|
return ret;
|
|
}
|
|
|
|
template<class Info_t = AVoid, class Result_t = AVoid, class Callable_t>
|
|
static inline FJob<Info_t, Result_t> JobFromResultConsumer(/*AuConsumer<const Result_t &> */ Callable_t onSuccess)
|
|
{
|
|
FJob<Info_t, Result_t> ret;
|
|
ret.onSuccess = [=](const Info_t &in, const Result_t &a)
|
|
{
|
|
onSuccess(a);
|
|
};
|
|
return ret;
|
|
}
|
|
|
|
template<typename Out_t = AVoid, typename ... Args, typename Callable_t>
|
|
FJob<AuTuple<Args...>, Out_t> JobFromTupleConsumer(/*AuConsumer<Args..., const Result_t &> */ Callable_t onSuccess)
|
|
{
|
|
FJob<AuTuple<Args...>, Out_t> ret;
|
|
ret.onSuccess = [=](const AuTuple<Args...> &in, const Out_t &a)
|
|
{
|
|
AuTupleApply(onSuccess, AuTupleCat(in, AuMakeTuple<const Out_t &>(a)));
|
|
};
|
|
return ret;
|
|
}
|
|
|
|
template<typename Out_t = AVoid, typename ... Args, typename Callable_t, typename FailureCallable_t>
|
|
FJob<AuTuple<Args...>, Out_t> JobFromTupleConsumerEx(/*AuConsumer<Args..., const Result_t &> */ Callable_t onSuccess, FailureCallable_t onFailure)
|
|
{
|
|
FJob<AuTuple<Args...>, Out_t> ret;
|
|
ret.onSuccess = [=](const AuTuple<Args...> &in, const Out_t &a)
|
|
{
|
|
AuTupleApply(onSuccess, AuTupleCat(in, AuMakeTuple<const Out_t &>(a)));
|
|
};
|
|
|
|
ret.onFailure = [=](const AuTuple<Args...> &in)
|
|
{
|
|
AuTupleApply(onFailure, in);
|
|
};
|
|
return ret;
|
|
}
|
|
|
|
template<class Info_t = AVoid, class Result_t = AVoid>
|
|
static inline FJob<Info_t, Result_t> JobFromPairConsumerEx(const AuConsumer<const Info_t &, const Result_t &> &onSuccess, const AuConsumer<const Info_t &> &onFailure)
|
|
{
|
|
FJob<Info_t, Result_t> ret;
|
|
ret.onSuccess = [=](const Info_t &in, const Result_t &a)
|
|
{
|
|
onSuccess(in, a);
|
|
};
|
|
ret.onFailure = [=](const Info_t &a)
|
|
{
|
|
onFailure(a);
|
|
};
|
|
return ret;
|
|
}
|
|
|
|
template<class Info_t = AVoid, class Result_t = AVoid>
|
|
static inline FJob<Info_t, Result_t> JobFromConsumer(const AuConsumer<const Result_t &> &onSuccess, const AuVoidFunc &onFailure)
|
|
{
|
|
FJob<Info_t, Result_t> ret;
|
|
ret.onSuccess = [=](const Info_t &in, const Result_t &a)
|
|
{
|
|
onSuccess(a);
|
|
};
|
|
ret.onFailure = [=](const Info_t &a)
|
|
{
|
|
onFailure();
|
|
};
|
|
return ret;
|
|
}
|
|
|
|
template<class Info_t = AVoid, class Result_t = AVoid, class BaseInfo_t = AVoid, class BaseResult_t = AVoid>
|
|
static inline FJob<Info_t, Result_t> JobFromDerivedJob(const FJob<BaseInfo_t, BaseResult_t> &reference)
|
|
{
|
|
FJob<Info_t, Result_t> ret;
|
|
ret.onSuccess = [=](const Info_t &in, const Result_t &a)
|
|
{
|
|
if (reference.onSuccess)
|
|
{
|
|
reference.onSuccess(in, a);
|
|
}
|
|
};
|
|
ret.onFailure = [=](const Info_t &a)
|
|
{
|
|
if (reference.onFailure)
|
|
{
|
|
reference.onFailure(a);
|
|
}
|
|
};
|
|
return ret;
|
|
}
|
|
|
|
template<typename ReturnValue_t = void, typename Arg0_t, typename ... Args>
|
|
static inline FJob<AuTuple<Arg0_t, Args...>, ReturnValue_t> JobFromTupleClazz(const AuConsumer<const Arg0_t &, const ReturnValue_t &> &onSuccess)
|
|
{
|
|
FJob<AuTuple<Arg0_t, Args...>, ReturnValue_t> ret;
|
|
ret.onSuccess = [=](const AuTuple<Arg0_t, Args...> &in, const ReturnValue_t &out)
|
|
{
|
|
onSuccess(AuGet<0>(in), out);
|
|
};
|
|
return ret;
|
|
}
|
|
|
|
template<typename ReturnValue_t = void, typename Arg0_t, typename ... Args>
|
|
static inline FJob<AuTuple<Arg0_t, Args...>, ReturnValue_t> JobFromTupleClazzEx(const AuConsumer<const Arg0_t &, const ReturnValue_t &> &onSuccess, const AuConsumer<const Arg0_t &> &onFailure)
|
|
{
|
|
FJob<AuTuple<Arg0_t, Args...>, ReturnValue_t> ret;
|
|
ret.onSuccess = [=](const AuTuple<Arg0_t, Args...> &in, const ReturnValue_t &out)
|
|
{
|
|
onSuccess(AuGet<0>(in), out);
|
|
};
|
|
|
|
ret.onFailure = [=](const AuTuple<Arg0_t, Args...> &in)
|
|
{
|
|
onFailure(AuGet<0>(in));
|
|
};
|
|
return ret;
|
|
}
|
|
|
|
#if 0
|
|
template<typename ReturnValue_t = void, typename Clazz_t, typename ... Args>
|
|
static inline FJob<AuTuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t> JobFromTupleClazz(const AuConsumer<const ReturnValue_t &> &onSuccess)
|
|
{
|
|
FJob<AuTuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t> ret;
|
|
ret.onSuccess = [=](const AuTuple<AuSPtr<Clazz_t>, Args...> &in, const ReturnValue_t &out)
|
|
{
|
|
onSuccess(out);
|
|
};
|
|
return ret;
|
|
}
|
|
|
|
template<typename ReturnValue_t = void, typename Clazz_t, typename ... Args>
|
|
static inline FJob<AuTuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t> JobFromTupleClazz(const AuConsumer<Args..., const ReturnValue_t &> &onSuccess)
|
|
{
|
|
FJob<AuTuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t> ret;
|
|
ret.onSuccess = [=](const AuTuple<AuSPtr<Clazz_t>, Args...> &in, const ReturnValue_t &out)
|
|
{
|
|
AuTupleApply(onSuccess, AuTupleCat(AuTuplePopFront(in), AuMakeTuple<const ReturnValue_t &>(out)));
|
|
};
|
|
return ret;
|
|
}
|
|
#endif
|
|
|
|
template<typename ReturnValue_t = void, typename ... Args>
|
|
static inline FJob<AuTuple<Args...>, ReturnValue_t> JobFromTupleResultConsumer(const AuConsumer<const ReturnValue_t &> &onSuccess)
|
|
{
|
|
FJob<AuTuple<Args...>, ReturnValue_t> ret;
|
|
ret.onSuccess = [=](const AuTuple<Args...> &in, const ReturnValue_t &out)
|
|
{
|
|
onSuccess(out);
|
|
};
|
|
return ret;
|
|
}
|
|
|
|
template<typename ReturnValue_t = void, typename ... Args>
|
|
static inline FJob<AuTuple<Args...>, ReturnValue_t> JobFromTuple(const AuConsumer<Args..., const ReturnValue_t &> &onSuccess)
|
|
{
|
|
FJob<AuTuple<Args...>, ReturnValue_t> ret;
|
|
ret.onSuccess = [=](const AuTuple<Args...> &in, const ReturnValue_t &out)
|
|
{
|
|
AuTupleApply(onSuccess, AuTupleCat(in, AuMakeTuple<const ReturnValue_t &>(out)));
|
|
};
|
|
return ret;
|
|
}
|
|
} |