2018-11-07 21:24:08 +01:00
|
|
|
/*
|
2019-03-15 02:37:38 +01:00
|
|
|
* IXSelectInterruptPipe.h
|
2018-11-07 21:24:08 +01:00
|
|
|
* Author: Benjamin Sergeant
|
2019-03-15 02:37:38 +01:00
|
|
|
* Copyright (c) 2018-2019 Machine Zone, Inc. All rights reserved.
|
2018-11-07 21:24:08 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-03-15 02:37:38 +01:00
|
|
|
#include "IXSelectInterrupt.h"
|
|
|
|
|
2019-03-14 07:09:45 +01:00
|
|
|
#include <stdint.h>
|
2019-03-15 02:37:38 +01:00
|
|
|
#include <string>
|
2019-03-14 07:09:45 +01:00
|
|
|
|
2019-02-21 03:59:07 +01:00
|
|
|
namespace ix
|
2018-11-07 21:24:08 +01:00
|
|
|
{
|
2019-03-15 02:37:38 +01:00
|
|
|
class SelectInterruptPipe : public SelectInterrupt {
|
2018-11-07 21:24:08 +01:00
|
|
|
public:
|
2019-03-15 02:37:38 +01:00
|
|
|
SelectInterruptPipe();
|
|
|
|
virtual ~SelectInterruptPipe();
|
|
|
|
|
|
|
|
bool init(std::string& errorMsg) final;
|
2018-11-07 21:24:08 +01:00
|
|
|
|
2019-03-15 02:37:38 +01:00
|
|
|
bool notify(uint64_t value) final;
|
|
|
|
bool clear() final;
|
|
|
|
uint64_t read() final;
|
|
|
|
int getFd() final;
|
2018-11-07 21:24:08 +01:00
|
|
|
|
|
|
|
private:
|
2019-03-14 07:09:45 +01:00
|
|
|
// Store file descriptors used by the communication pipe. Communication
|
|
|
|
// happens between a control thread and a background thread, which is
|
|
|
|
// blocked on select.
|
|
|
|
int _fildes[2];
|
2019-03-14 23:03:57 +01:00
|
|
|
|
|
|
|
// Used to identify the read/write idx
|
|
|
|
static const int kPipeReadIndex;
|
|
|
|
static const int kPipeWriteIndex;
|
2018-11-07 21:24:08 +01:00
|
|
|
};
|
|
|
|
}
|
2019-03-15 02:37:38 +01:00
|
|
|
|