This commit is contained in:
azw 2023-08-19 00:01:32 +08:00
parent 0d5c381b38
commit 888275763f
2 changed files with 24 additions and 2 deletions

12
a8/promise.cc Normal file
View File

@ -0,0 +1,12 @@
#include <a8/a8.h>
#include <a8/promise.h>
namespace a8
{
void CbPromise::DoAwait()
{
cb_(Awaiter::shared_from_this());
}
}

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <a8/awaiter.h>
namespace a8 namespace a8
{ {
@ -7,9 +9,17 @@ namespace a8
{ {
}; };
class NormalPromise : public Awaiter class CbPromise : public Awaiter
{ {
std::function<(std::shared_ptr<a8::Awaiter>)> cb; public:
CbPromise(std::function<void (std::shared_ptr<a8::Awaiter>)> cb):Awaiter()
{ cb_ = cb; }
protected:
virtual void DoAwait() override;
private:
std::function<void (std::shared_ptr<a8::Awaiter>)> cb_;
}; };
} }