Merge tag 'v3.10.54' into linux-linaro-lsk
[firefly-linux-kernel-4.4.55.git] / tools / gator / daemon / ExternalSource.h
1 /**
2  * Copyright (C) ARM Limited 2010-2014. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  */
8
9 #ifndef EXTERNALSOURCE_H
10 #define EXTERNALSOURCE_H
11
12 #include <semaphore.h>
13
14 #include "Buffer.h"
15 #include "Monitor.h"
16 #include "OlySocket.h"
17 #include "Source.h"
18
19 // Unix domain socket counters from external sources like graphics drivers
20 class ExternalSource : public Source {
21 public:
22         ExternalSource(sem_t *senderSem);
23         ~ExternalSource();
24
25         bool prepare();
26         void run();
27         void interrupt();
28
29         bool isDone();
30         void write(Sender *sender);
31
32 private:
33         void waitFor(const uint64_t currTime, const int bytes);
34         void configureConnection(const int fd, const char *const handshake, size_t size);
35         bool connectMve();
36
37         sem_t mBufferSem;
38         Buffer mBuffer;
39         Monitor mMonitor;
40         OlyServerSocket mMveStartupUds;
41         int mInterruptFd;
42         int mMveUds;
43
44         // Intentionally unimplemented
45         ExternalSource(const ExternalSource &);
46         ExternalSource &operator=(const ExternalSource &);
47 };
48
49 #endif // EXTERNALSOURCE_H