From 17b9035bcd162f59e1a1247d4a755124c37052c5 Mon Sep 17 00:00:00 2001 From: Carl Jackson Date: Mon, 28 Jul 2014 02:12:27 -0700 Subject: [PATCH] Add App Engine support App Engine disallows package unsafe. As a workaround for the (unsafe) RCU atomic pointer shenanigans we pull in order to avoid taking a lock in the hot routing path, let's just grab the lock. Honestly, I doubt anyone will notice anyways, especially considering the fact that App Engine is single-threaded anyways. Fixes #52. --- web/atomic.go | 2 ++ web/atomic_appengine.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 web/atomic_appengine.go diff --git a/web/atomic.go b/web/atomic.go index aab483a..795d8e5 100644 --- a/web/atomic.go +++ b/web/atomic.go @@ -1,3 +1,5 @@ +// +build !appengine + package web import ( diff --git a/web/atomic_appengine.go b/web/atomic_appengine.go new file mode 100644 index 0000000..027127a --- /dev/null +++ b/web/atomic_appengine.go @@ -0,0 +1,14 @@ +// +build appengine + +package web + +func (rt *router) getMachine() *routeMachine { + rt.lock.Lock() + defer rt.lock.Unlock() + return rt.machine +} + +// We always hold the lock when calling setMachine. +func (rt *router) setMachine(m *routeMachine) { + rt.machine = m +}