diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-14 08:52:21 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-12-14 08:52:21 +0000 |
commit | d0b175bffc2f2cb91d1fb529b7c36d3e984d9594 (patch) | |
tree | eb438cb5c7cabed8d102b2c0c1bdd1b0aebb59eb /libgo/go/old | |
parent | 5e3123db0a9b4c8def9fee64446b130ce81ace45 (diff) | |
download | gcc-d0b175bffc2f2cb91d1fb529b7c36d3e984d9594.tar.gz |
2011-12-14 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 182322 using svnmerge
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@182325 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/old')
-rw-r--r-- | libgo/go/old/netchan/common.go | 12 | ||||
-rw-r--r-- | libgo/go/old/netchan/export.go | 14 | ||||
-rw-r--r-- | libgo/go/old/netchan/import.go | 4 |
3 files changed, 15 insertions, 15 deletions
diff --git a/libgo/go/old/netchan/common.go b/libgo/go/old/netchan/common.go index dfd1fd03427..03fa8ff6c41 100644 --- a/libgo/go/old/netchan/common.go +++ b/libgo/go/old/netchan/common.go @@ -129,8 +129,8 @@ func (ed *encDec) encode(hdr *header, payloadType int, payload interface{}) erro } // See the comment for Exporter.Drain. -func (cs *clientSet) drain(timeout int64) error { - startTime := time.Nanoseconds() +func (cs *clientSet) drain(timeout time.Duration) error { + deadline := time.Now().Add(timeout) for { pending := false cs.mu.Lock() @@ -152,7 +152,7 @@ func (cs *clientSet) drain(timeout int64) error { if !pending { break } - if timeout > 0 && time.Nanoseconds()-startTime >= timeout { + if timeout > 0 && time.Now().After(deadline) { return errors.New("timeout") } time.Sleep(100 * 1e6) // 100 milliseconds @@ -161,8 +161,8 @@ func (cs *clientSet) drain(timeout int64) error { } // See the comment for Exporter.Sync. -func (cs *clientSet) sync(timeout int64) error { - startTime := time.Nanoseconds() +func (cs *clientSet) sync(timeout time.Duration) error { + deadline := time.Now().Add(timeout) // seq remembers the clients and their seqNum at point of entry. seq := make(map[unackedCounter]int64) for client := range cs.clients { @@ -185,7 +185,7 @@ func (cs *clientSet) sync(timeout int64) error { if !pending { break } - if timeout > 0 && time.Nanoseconds()-startTime >= timeout { + if timeout > 0 && time.Now().After(deadline) { return errors.New("timeout") } time.Sleep(100 * 1e6) // 100 milliseconds diff --git a/libgo/go/old/netchan/export.go b/libgo/go/old/netchan/export.go index d698dd53a90..d94c4b16b21 100644 --- a/libgo/go/old/netchan/export.go +++ b/libgo/go/old/netchan/export.go @@ -29,6 +29,7 @@ import ( "reflect" "strconv" "sync" + "time" ) // Export @@ -322,9 +323,9 @@ func (exp *Exporter) delClient(client *expClient) { // those not yet sent to any client and possibly including those sent while // Drain was executing, have been received by the importer. In short, it // waits until all the exporter's messages have been received by a client. -// If the timeout (measured in nanoseconds) is positive and Drain takes -// longer than that to complete, an error is returned. -func (exp *Exporter) Drain(timeout int64) error { +// If the timeout is positive and Drain takes longer than that to complete, +// an error is returned. +func (exp *Exporter) Drain(timeout time.Duration) error { // This wrapper function is here so the method's comment will appear in godoc. return exp.clientSet.drain(timeout) } @@ -332,10 +333,9 @@ func (exp *Exporter) Drain(timeout int64) error { // Sync waits until all clients of the exporter have received the messages // that were sent at the time Sync was invoked. Unlike Drain, it does not // wait for messages sent while it is running or messages that have not been -// dispatched to any client. If the timeout (measured in nanoseconds) is -// positive and Sync takes longer than that to complete, an error is -// returned. -func (exp *Exporter) Sync(timeout int64) error { +// dispatched to any client. If the timeout is positive and Sync takes longer +// than that to complete, an error is returned. +func (exp *Exporter) Sync(timeout time.Duration) error { // This wrapper function is here so the method's comment will appear in godoc. return exp.clientSet.sync(timeout) } diff --git a/libgo/go/old/netchan/import.go b/libgo/go/old/netchan/import.go index 7243672ecd3..a6da8210b99 100644 --- a/libgo/go/old/netchan/import.go +++ b/libgo/go/old/netchan/import.go @@ -276,9 +276,9 @@ func (imp *Importer) unackedCount() int64 { // If the timeout (measured in nanoseconds) is positive and Drain takes // longer than that to complete, an error is returned. func (imp *Importer) Drain(timeout int64) error { - startTime := time.Nanoseconds() + deadline := time.Now().Add(time.Duration(timeout)) for imp.unackedCount() > 0 { - if timeout > 0 && time.Nanoseconds()-startTime >= timeout { + if timeout > 0 && time.Now().After(deadline) { return errors.New("timeout") } time.Sleep(100 * 1e6) |