Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
73120ee8
Commit
73120ee8
authored
Dec 05, 2008
by
Rob Pike
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use sync.Mutex instead of a channel for locking
R=rsc DELTA=12 (3 added, 1 deleted, 8 changed) OCL=20631 CL=20634
parent
cc352e5c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
Makefile
src/lib/Makefile
+1
-1
type.go
src/lib/reflect/type.go
+5
-4
No files found.
src/lib/Makefile
View file @
73120ee8
...
@@ -97,7 +97,7 @@ io.dirinstall: os.dirinstall syscall.dirinstall
...
@@ -97,7 +97,7 @@ io.dirinstall: os.dirinstall syscall.dirinstall
net.dirinstall
:
once.install os.dirinstall strconv.dirinstall
net.dirinstall
:
once.install os.dirinstall strconv.dirinstall
os.dirinstall
:
syscall.dirinstall
os.dirinstall
:
syscall.dirinstall
regexp.dirinstall
:
os.dirinstall
regexp.dirinstall
:
os.dirinstall
reflect.dirinstall
:
strconv.dirinstall
reflect.dirinstall
:
strconv.dirinstall
sync.dirinstall
strconv.dirinstall
:
os.dirinstall utf8.install
strconv.dirinstall
:
os.dirinstall utf8.install
tabwriter.dirinstall
:
os.dirinstall io.dirinstall container/array.dirinstall
tabwriter.dirinstall
:
os.dirinstall io.dirinstall container/array.dirinstall
time.dirinstall
:
once.install os.dirinstall
time.dirinstall
:
once.install os.dirinstall
...
...
src/lib/reflect/type.go
View file @
73120ee8
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
package
reflect
package
reflect
import
"sync"
export
type
Type
interface
export
type
Type
interface
export
func
ExpandType
(
name
string
)
Type
export
func
ExpandType
(
name
string
)
Type
...
@@ -390,21 +392,20 @@ var MissingStub *StubType;
...
@@ -390,21 +392,20 @@ var MissingStub *StubType;
var
DotDotDotStub
*
StubType
;
var
DotDotDotStub
*
StubType
;
// The database stored in the maps is global; use locking to guarantee safety.
// The database stored in the maps is global; use locking to guarantee safety.
var
lockchan
*
chan
bool
// Channel with buffer of 1, used as a m
utex
var
typestringlock
sync
.
M
utex
func
Lock
()
{
func
Lock
()
{
lockchan
<-
true
// block if buffer is full
typestringlock
.
Lock
()
}
}
func
Unlock
()
{
func
Unlock
()
{
<-
lockchan
// release waiters
typestringlock
.
Unlock
()
}
}
func
init
()
{
func
init
()
{
ptrsize
=
8
;
// TODO: compute this
ptrsize
=
8
;
// TODO: compute this
interfacesize
=
2
*
ptrsize
;
// TODO: compute this
interfacesize
=
2
*
ptrsize
;
// TODO: compute this
lockchan
=
new
(
chan
bool
,
1
);
// unlocked at creation - buffer is empty
Lock
();
// not necessary because of init ordering but be safe.
Lock
();
// not necessary because of init ordering but be safe.
types
=
new
(
map
[
string
]
*
Type
);
types
=
new
(
map
[
string
]
*
Type
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment