diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2013-03-05 09:38:15 +0200 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2013-03-05 09:38:15 +0200 |
| commit | d0c11d20b8eeebcdf2ab597c3b494e40287f9c9b (patch) | |
| tree | ce5b3de97c300f7eeab0e65d80e96c17543bd6c5 /src/pkg/runtime | |
| parent | db018bf77cba282220d852f19203570ae5e87c37 (diff) | |
| download | go-d0c11d20b8eeebcdf2ab597c3b494e40287f9c9b.tar.xz | |
runtime: declare addtimer/deltimer in runtime.h
In preparation for integrated network poller
(https://golang.org/cl/7326051),
this is required to handle deadlines.
R=golang-dev, remyoudompheng, rsc
CC=golang-dev
https://golang.org/cl/7446047
Diffstat (limited to 'src/pkg/runtime')
| -rw-r--r-- | src/pkg/runtime/runtime.h | 2 | ||||
| -rw-r--r-- | src/pkg/runtime/time.goc | 19 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/pkg/runtime/runtime.h b/src/pkg/runtime/runtime.h index 9b43f29a59..585d6a536e 100644 --- a/src/pkg/runtime/runtime.h +++ b/src/pkg/runtime/runtime.h @@ -761,6 +761,8 @@ int64 runtime·cputicks(void); int64 runtime·tickspersecond(void); void runtime·blockevent(int64, int32); extern int64 runtime·blockprofilerate; +void runtime·addtimer(Timer*); +bool runtime·deltimer(Timer*); #pragma varargck argpos runtime·printf 1 #pragma varargck type "d" int32 diff --git a/src/pkg/runtime/time.goc b/src/pkg/runtime/time.goc index 2babb173df..6de989f515 100644 --- a/src/pkg/runtime/time.goc +++ b/src/pkg/runtime/time.goc @@ -15,7 +15,6 @@ package time static Timers timers; static void addtimer(Timer*); -static bool deltimer(Timer*); // Package time APIs. // Godoc uses the comments in package time, not these. @@ -31,15 +30,13 @@ func Sleep(ns int64) { func startTimer(t *Timer) { if(raceenabled) runtime·racerelease(t); - runtime·lock(&timers); - addtimer(t); - runtime·unlock(&timers); + runtime·addtimer(t); } // stopTimer removes t from the timer heap if it is there. // It returns true if t was removed, false if t wasn't even there. func stopTimer(t *Timer) (stopped bool) { - stopped = deltimer(t); + stopped = runtime·deltimer(t); } // C runtime. @@ -79,6 +76,14 @@ runtime·tsleep(int64 ns, int8 *reason) static FuncVal timerprocv = {timerproc}; +void +runtime·addtimer(Timer *t) +{ + runtime·lock(&timers); + addtimer(t); + runtime·unlock(&timers); +} + // Add a timer to the heap and start or kick the timer proc // if the new timer is earlier than any of the others. static void @@ -121,8 +126,8 @@ addtimer(Timer *t) // Delete timer t from the heap. // Do not need to update the timerproc: // if it wakes up early, no big deal. -static bool -deltimer(Timer *t) +bool +runtime·deltimer(Timer *t) { int32 i; |
