1
This commit is contained in:
parent
0d5c381b38
commit
888275763f
12
a8/promise.cc
Normal file
12
a8/promise.cc
Normal file
@ -0,0 +1,12 @@
|
||||
#include <a8/a8.h>
|
||||
#include <a8/promise.h>
|
||||
|
||||
namespace a8
|
||||
{
|
||||
|
||||
void CbPromise::DoAwait()
|
||||
{
|
||||
cb_(Awaiter::shared_from_this());
|
||||
}
|
||||
|
||||
}
|
14
a8/promise.h
14
a8/promise.h
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <a8/awaiter.h>
|
||||
|
||||
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_;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user