Files

69 lines
1.7 KiB
C++
Raw Permalink Normal View History

2019-01-06 11:11:21 +01:00
/*
Low Latency IPC Library for high-speed traffic
2019-01-06 11:17:01 +01:00
Copyright (C) 2019 Michael Fabian Dirks <info@xaymar.com>
2019-01-06 11:11:21 +01:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "task.hpp"
2020-01-23 01:51:15 +01:00
datapath::windows::task::task()
{
_overlapped.set_callback(std::bind(&datapath::windows::task::handle_overlapped, this, std::placeholders::_1,
std::placeholders::_2, std::placeholders::_3));
}
2019-01-07 00:22:13 +01:00
2020-01-23 01:51:15 +01:00
datapath::windows::task::~task()
2020-01-23 01:51:15 +01:00
{
2020-01-23 01:51:15 +01:00
cancel();
2019-01-06 11:11:21 +01:00
}
2020-01-23 01:51:15 +01:00
::datapath::windows::overlapped& datapath::windows::task::overlapped()
2019-01-06 11:11:21 +01:00
{
2020-01-23 01:51:15 +01:00
return _overlapped;
2019-01-06 11:11:21 +01:00
}
2020-01-23 01:51:15 +01:00
std::vector<char>& datapath::windows::task::get_data()
2019-01-06 11:11:21 +01:00
{
2020-01-23 01:51:15 +01:00
return _data;
2019-01-06 11:11:21 +01:00
}
2020-01-23 01:51:15 +01:00
void datapath::windows::task::handle_overlapped(::datapath::windows::overlapped& ov, size_t bytes, void* ptr)
2019-01-06 11:11:21 +01:00
{
2020-01-23 01:51:15 +01:00
DWORD _bytes = 0;
if (GetOverlappedResult(_overlapped.get_handle(), _overlapped.get_overlapped(), &_bytes, false)) {
2019-01-06 11:11:21 +01:00
}
}
2020-01-23 01:51:15 +01:00
datapath::error datapath::windows::task::cancel()
2019-01-06 11:11:21 +01:00
{
2020-01-23 01:51:15 +01:00
_overlapped.cancel();
return datapath::error::Success;
2019-01-06 11:11:21 +01:00
}
2020-01-23 01:51:15 +01:00
bool datapath::windows::task::is_completed()
2019-01-06 11:11:21 +01:00
{
2020-01-23 01:51:15 +01:00
return _overlapped.is_completed();
2019-01-06 11:11:21 +01:00
}
2020-01-23 01:51:15 +01:00
size_t datapath::windows::task::length()
2019-01-06 11:11:21 +01:00
{
2020-01-23 01:51:15 +01:00
return _data.size();
2019-01-06 11:11:21 +01:00
}
2020-01-23 01:51:15 +01:00
const std::vector<char>& datapath::windows::task::data()
2019-01-06 11:11:21 +01:00
{
2020-01-23 01:51:15 +01:00
return _data;
2019-01-06 11:11:21 +01:00
}