remove operator-> from String
[hiphop-php.git] / hphp / runtime / vm / treadmill.h
blobd360b4750beb1056d00096c8e940ad4a26f6fe59
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2014 Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_TREADMILL_H_
18 #define incl_HPHP_TREADMILL_H_
20 #include <stdint.h>
21 #include <memory>
23 namespace HPHP {
25 class Class;
26 class Typedef;
28 namespace Treadmill {
31 * The Treadmill allows us to defer work until all currently-outstanding
32 * requests have finished. We hook request start and finish. To defer
33 * work, inherit from WorkItem and call Treadmill::WorkItem::enqueue.
35 * The work item will be called from base rank.
37 void startRequest();
38 void finishRequest();
41 * Returns the oldest start time in seconds of all requests in flight.
42 * If there are no requests in flight the return value is 0.
43 * The value returned should be used as a conservative and true value
44 * for the oldest start time of any request in flight. In that sense
45 * the value is safe to compare against in a less-than relationship.
47 int64_t getOldestStartTime();
50 * Ask for memory to be freed (as in free, not delete) by the next
51 * appropriate treadmill round.
53 void deferredFree(void*);
55 typedef int64_t GenCount;
57 class WorkItem {
58 protected:
59 GenCount m_gen;
60 friend void finishRequest();
62 public:
63 WorkItem();
64 virtual ~WorkItem() { }
65 virtual void operator()() = 0; // doesn't throw.
66 static void enqueue(std::unique_ptr<WorkItem> gt);
69 class FreeMemoryTrigger : public WorkItem {
70 void* m_ptr;
71 public:
72 explicit FreeMemoryTrigger(void* ptr);
73 virtual void operator()();
78 #endif