source: trash/InterruptableSleeper.h@ 12060

Last change on this file since 12060 was 12060, checked in by hock@…, 11 years ago

Reintegrate branch: 20130111-hock-message_classes

improvements:

  • new message classes (reboost, zero-copy)
  • "fast path" for direct links (skip overlay layer)
  • link-properties accessible from the application
  • SystemQueue can call boost::bind functions
  • protlib compatibility removed (32bit overhead saved in every message)
  • addressing2
  • AddressDiscovery discoveres only addresses on which we're actually listening
  • ariba serialization usage reduced (sill used in OverlayMsg)
  • Node::connect, easier and cleaner interface to start-up ariba from the application
  • ariba configs via JSON, XML, etc (boost::property_tree)
  • keep-alive overhead greatly reduced
  • (relayed) overlay links can actually be closed now
  • lost messages are detected in most cases
  • notification to the application when link is transformed into direct-link
  • overlay routing: send message to second best hop if it would be dropped otherwise
  • SequenceNumbers (only mechanisms, so for: upward compatibility)
  • various small fixes


regressions:

  • bluetooth is not yet working again
  • bootstrap modules deactivated
  • liblog4xx is not working (use cout-logging)

This patch brings great performance and stability improvements at cost of backward compatibility.
Also bluetooth and the bootstrap modules have not been ported to the new interfaces, yet.

File size: 921 bytes
Line 
1#ifndef __INTERRUPTABLE_SLEEPER_H
2#define __INTERRUPTABLE_SLEEPER_H
3
4#include <boost/thread/mutex.hpp>
5#include <cassert>
6#include <iostream>
7
8using std::cout;
9
10#ifdef WIN32
11#define WIN32_LEAN_AND_MEAN
12#include <windows.h>
13#else
14#include <pthread.h>
15#include <time.h>
16#include <stdio.h>
17#include <stdlib.h>
18#include <sys/types.h>
19#include <sys/timeb.h>
20#include <unistd.h>
21#include <errno.h>
22#endif
23
24namespace spovnet {
25namespace common {
26
27class InterruptableSleeper {
28public:
29 InterruptableSleeper();
30 ~InterruptableSleeper();
31
32 void sleep(unsigned long millis);
33 void interrupt();
34
35private:
36
37#ifdef WIN32
38 HANDLE m_handle;
39#else
40 typedef struct _MUTEX_COND {
41 pthread_cond_t cond;
42 pthread_mutex_t mutex;
43 } MUTEX_COND, *PMUTEX_COND;
44
45 PMUTEX_COND m_handle;
46#endif
47
48 boost::mutex m_mutex;
49};
50
51}
52} // namespace spovnet, common
53
54#endif // __INTERRUPTABLE_SLEEPER_H
Note: See TracBrowser for help on using the repository browser.