* try to use a pipe for communication * flush send buffer on the background thread * cleanup * linux fix / linux still use event fd for now * cleanup
		
			
				
	
	
		
			34 lines
		
	
	
		
			645 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			645 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  *  IXEventFd.h
 | |
|  *  Author: Benjamin Sergeant
 | |
|  *  Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <stdint.h>
 | |
| 
 | |
| namespace ix
 | |
| {
 | |
|     class EventFd {
 | |
|     public:
 | |
|         EventFd();
 | |
|         virtual ~EventFd();
 | |
| 
 | |
|         bool notify(uint64_t value);
 | |
|         bool clear();
 | |
|         uint64_t read();
 | |
|         int getFd();
 | |
| 
 | |
|     private:
 | |
| #if defined(__linux__)
 | |
|         int _eventfd;
 | |
| #else
 | |
|         // 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];
 | |
| #endif
 | |
|     };
 | |
| }
 |