Commit 31e4ad58 authored by Dmitriy Vyukov's avatar Dmitriy Vyukov

runtime: remove now arg from timer callback

Cleanup before converting to Go.
Fortunately nobody using it, because it is incorrect:
monotonic runtime time instead of claimed real time.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rsc
https://golang.org/cl/129480043
parent 684de041
...@@ -74,9 +74,9 @@ static struct ...@@ -74,9 +74,9 @@ static struct
static bool netpollblock(PollDesc*, int32, bool); static bool netpollblock(PollDesc*, int32, bool);
static G* netpollunblock(PollDesc*, int32, bool); static G* netpollunblock(PollDesc*, int32, bool);
static void deadline(int64, Eface); static void deadline(Eface);
static void readDeadline(int64, Eface); static void readDeadline(Eface);
static void writeDeadline(int64, Eface); static void writeDeadline(Eface);
static PollDesc* allocPollDesc(void); static PollDesc* allocPollDesc(void);
static intgo checkerr(PollDesc *pd, int32 mode); static intgo checkerr(PollDesc *pd, int32 mode);
...@@ -384,13 +384,12 @@ netpollunblock(PollDesc *pd, int32 mode, bool ioready) ...@@ -384,13 +384,12 @@ netpollunblock(PollDesc *pd, int32 mode, bool ioready)
} }
static void static void
deadlineimpl(int64 now, Eface arg, bool read, bool write) deadlineimpl(Eface arg, bool read, bool write)
{ {
PollDesc *pd; PollDesc *pd;
uint32 seq; uint32 seq;
G *rg, *wg; G *rg, *wg;
USED(now);
pd = (PollDesc*)arg.data; pd = (PollDesc*)arg.data;
// This is the seq when the timer was set. // This is the seq when the timer was set.
// If it's stale, ignore the timer event. // If it's stale, ignore the timer event.
...@@ -424,21 +423,21 @@ deadlineimpl(int64 now, Eface arg, bool read, bool write) ...@@ -424,21 +423,21 @@ deadlineimpl(int64 now, Eface arg, bool read, bool write)
} }
static void static void
deadline(int64 now, Eface arg) deadline(Eface arg)
{ {
deadlineimpl(now, arg, true, true); deadlineimpl(arg, true, true);
} }
static void static void
readDeadline(int64 now, Eface arg) readDeadline(Eface arg)
{ {
deadlineimpl(now, arg, true, false); deadlineimpl(arg, true, false);
} }
static void static void
writeDeadline(int64 now, Eface arg) writeDeadline(Eface arg)
{ {
deadlineimpl(now, arg, false, true); deadlineimpl(arg, false, true);
} }
static PollDesc* static PollDesc*
......
...@@ -70,10 +70,8 @@ static void siftdown(int32); ...@@ -70,10 +70,8 @@ static void siftdown(int32);
// Ready the goroutine e.data. // Ready the goroutine e.data.
static void static void
ready(int64 now, Eface e) ready(Eface e)
{ {
USED(now);
runtime·ready(e.data); runtime·ready(e.data);
} }
...@@ -201,7 +199,7 @@ timerproc(void) ...@@ -201,7 +199,7 @@ timerproc(void)
{ {
int64 delta, now; int64 delta, now;
Timer *t; Timer *t;
void (*f)(int64, Eface); void (*f)(Eface);
Eface arg; Eface arg;
for(;;) { for(;;) {
...@@ -233,7 +231,7 @@ timerproc(void) ...@@ -233,7 +231,7 @@ timerproc(void)
runtime·unlock(&timers.lock); runtime·unlock(&timers.lock);
if(raceenabled) if(raceenabled)
runtime·raceacquire(t); runtime·raceacquire(t);
f(now, arg); f(arg);
// clear f and arg to avoid leak while sleeping for next timer // clear f and arg to avoid leak while sleeping for next timer
f = nil; f = nil;
......
...@@ -12,7 +12,7 @@ func init() { ...@@ -12,7 +12,7 @@ func init() {
var Interrupt = interrupt var Interrupt = interrupt
var DaysIn = daysIn var DaysIn = daysIn
func empty(now int64, arg interface{}) {} func empty(arg interface{}) {}
// Test that a runtimeTimer with a duration so large it overflows // Test that a runtimeTimer with a duration so large it overflows
// does not cause other timers to hang. // does not cause other timers to hang.
......
...@@ -17,7 +17,7 @@ type runtimeTimer struct { ...@@ -17,7 +17,7 @@ type runtimeTimer struct {
i int32 i int32
when int64 when int64
period int64 period int64
f func(int64, interface{}) // NOTE: must not be closure f func(interface{}) // NOTE: must not be closure
arg interface{} arg interface{}
} }
...@@ -83,7 +83,7 @@ func (t *Timer) Reset(d Duration) bool { ...@@ -83,7 +83,7 @@ func (t *Timer) Reset(d Duration) bool {
return active return active
} }
func sendTime(now int64, c interface{}) { func sendTime(c interface{}) {
// Non-blocking send of time on c. // Non-blocking send of time on c.
// Used in NewTimer, it cannot block anyway (buffer). // Used in NewTimer, it cannot block anyway (buffer).
// Used in NewTicker, dropping sends on the floor is // Used in NewTicker, dropping sends on the floor is
...@@ -117,6 +117,6 @@ func AfterFunc(d Duration, f func()) *Timer { ...@@ -117,6 +117,6 @@ func AfterFunc(d Duration, f func()) *Timer {
return t return t
} }
func goFunc(now int64, arg interface{}) { func goFunc(arg interface{}) {
go arg.(func())() go arg.(func())()
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment