From 23f6a07c7f82f9107554c5a5e228d3364652ef3e Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Tue, 18 Feb 2014 10:53:15 -0500 Subject: Buffered the event channels, as per skelterjohn's suggestion; I thought this would fix the faults I now get, but it doesn't... --- sysdata.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'sysdata.go') diff --git a/sysdata.go b/sysdata.go index da94766..5a3f0ab 100644 --- a/sysdata.go +++ b/sysdata.go @@ -5,6 +5,13 @@ import ( "runtime" ) +const eventbufsiz = 100 // suggested by skelterjohn + +// Event returns a new channel suitable for listening for events. +func Event() chan struct{} { + return make(chan struct{}, eventbufsiz) +} + // The sysData type contains all system data. It provides the system-specific underlying implementation. It is guaranteed to have the following by embedding: type cSysData struct { ctype int @@ -56,7 +63,7 @@ func (c *cSysData) delete(int) error { } // signal sends the event signal. This raise is done asynchronously to avoid deadlocking the UI task. -// Thanks skelterjohn for this techinque: if we can't queue any more events, drop them; TODO this would be best if the channel is buffered +// Thanks skelterjohn for this techinque: if we can't queue any more events, drop them func (s *cSysData) signal() { if s.event != nil { go func() { -- cgit v1.2.3