Files
workflow/src/kernel/SleepRequest.h
T
xiehan 65473be586 Change some includes to forward declarations (#57)
* Make thrdpool stronger

* Fix some comments

* fix grammar

* change some include to forward declaration

* remove some typedef

* move codes

Co-authored-by: XieHan <XieHan@sogou-inc.com>
2020-09-18 15:08:43 +00:00

63 lines
1.3 KiB
C++

/*
Copyright (c) 2019 Sogou, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Author: Xie Han (xiehan@sogou-inc.com)
*/
#ifndef _SLEEPREQUEST_H_
#define _SLEEPREQUEST_H_
#include "SubTask.h"
#include "Communicator.h"
#include "CommScheduler.h"
class SleepRequest : public SubTask, public SleepSession
{
public:
SleepRequest(CommScheduler *scheduler)
{
this->scheduler = scheduler;
}
public:
virtual void dispatch()
{
if (this->scheduler->sleep(this) < 0)
{
this->state = SS_STATE_ERROR;
this->error = errno;
this->subtask_done();
}
}
protected:
int state;
int error;
protected:
CommScheduler *scheduler;
protected:
virtual void handle(int state, int error)
{
this->state = state;
this->error = error;
this->subtask_done();
}
};
#endif