2 +----------------------------------------------------------------------+
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_
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.
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
;
60 friend void finishRequest();
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
{
72 explicit FreeMemoryTrigger(void* ptr
);
73 virtual void operator()();