folly: AsyncIO: add debuging helper
[folly.git] / folly / experimental / io / AsyncIO.h
index 3c84ebb0c4f2be331669ffb88b379fdfb8fbbfc3..0421796995dce193aa28e4082a3b294c179d894c 100644 (file)
@@ -24,6 +24,7 @@
 #include <cstdint>
 #include <deque>
 #include <functional>
+#include <ostream>
 #include <utility>
 #include <vector>
 
@@ -42,6 +43,7 @@ namespace folly {
  */
 class AsyncIOOp : private boost::noncopyable {
   friend class AsyncIO;
+  friend std::ostream& operator<<(std::ostream& stream, const AsyncIOOp& o);
  public:
   typedef std::function<void(AsyncIOOp*)> NotificationCallback;
 
@@ -51,7 +53,7 @@ class AsyncIOOp : private boost::noncopyable {
   // There would be a cancel() method here if Linux AIO actually implemented
   // it.  But let's not get your hopes up.
 
-  enum State {
+  enum class State {
     UNINITIALIZED,
     INITIALIZED,
     PENDING,
@@ -108,6 +110,9 @@ class AsyncIOOp : private boost::noncopyable {
   ssize_t result_;
 };
 
+std::ostream& operator<<(std::ostream& stream, const AsyncIOOp& o);
+std::ostream& operator<<(std::ostream& stream, AsyncIOOp::State state);
+
 /**
  * C++ interface around Linux Async IO.
  */