chunk_id large_stringlengths 36 36 | doc_type large_stringclasses 2
values | category large_stringclasses 17
values | document large_stringclasses 50
values | version_raw large_stringclasses 590
values | chunk_index int64 0 262 | text large_stringlengths 11 5.69k | file_path large_stringclasses 882
values |
|---|---|---|---|---|---|---|---|
6a100d34-9626-51f3-8f2c-64e530e7adc5 | docs | golang | golang_sync | go119 | 7 | read and write operations are defined as follows.
Load, LoadAndDelete, LoadOrStore are read operations;
Delete, LoadAndDelete, and Store are write operations;
and LoadOrStore is a write operation when it returns loaded set to false.
#### func (\*Map) [Delete](https://cs.opensource.google/go/go/+/go1.19:src/sync/map.go... | large_dataset/raw/docs/golang/sync/sync_go119.md |
81084193-d4db-5879-aaf7-a981ec5e8955 | docs | golang | golang_sync | go119 | 8 | #### func (\*Map) [LoadAndDelete](https://cs.opensource.google/go/go/+/go1.19:src/sync/map.go;l=276) [¶](#Map.LoadAndDelete "Go to Map.LoadAndDelete") added in go1.15
```None
func (m *Map) LoadAndDelete(key any) (value any, loaded bool)
```
LoadAndDelete deletes the value for a key, returning the previous value if an... | large_dataset/raw/docs/golang/sync/sync_go119.md |
5364982f-15fb-5b76-b450-1b6842ab5b11 | docs | golang | golang_sync | go119 | 9 | #### func (\*Map) [Range](https://cs.opensource.google/go/go/+/go1.19:src/sync/map.go;l=327) [¶](#Map.Range "Go to Map.Range") added in go1.9
```None
func (m *Map) Range(f func(key, value any) bool)
```
Range calls f sequentially for each key and value present in the map.
If f returns false, range stops the iteration... | large_dataset/raw/docs/golang/sync/sync_go119.md |
8c5f2b02-25e1-5ff0-8849-d56fade6f602 | docs | golang | golang_sync | go119 | 10 | #### func (\*Map) [Store](https://cs.opensource.google/go/go/+/go1.19:src/sync/map.go;l=144) [¶](#Map.Store "Go to Map.Store") added in go1.9
```None
func (m *Map) Store(key, value any)
```
Store sets the value for a key.
#### type [Mutex](https://cs.opensource.google/go/go/+/go1.19:src/sync/mutex.go;l=34) [¶](#Mute... | large_dataset/raw/docs/golang/sync/sync_go119.md |
fc8326d7-a15b-5f1d-9e88-dc8f8a835c09 | docs | golang | golang_sync | go119 | 11 | #### func (\*Mutex) [Lock](https://cs.opensource.google/go/go/+/go1.19:src/sync/mutex.go;l=81) [¶](#Mutex.Lock "Go to Mutex.Lock")
```None
func (m *Mutex) Lock()
```
Lock locks m.
If the lock is already in use, the calling goroutine
blocks until the mutex is available.
#### func (\*Mutex) [TryLock](https://cs.openso... | large_dataset/raw/docs/golang/sync/sync_go119.md |
dea6d3b6-99a7-54f5-a444-8f009aa5bedc | docs | golang | golang_sync | go119 | 12 | It is allowed for one goroutine to lock a Mutex and then
arrange for another goroutine to unlock it.
#### type [Once](https://cs.opensource.google/go/go/+/go1.19:src/sync/once.go;l=18) [¶](#Once "Go to Once")
```None
type Once struct {
// contains filtered or unexported fields
}
```
Once is an object that will perf... | large_dataset/raw/docs/golang/sync/sync_go119.md |
f3d5de1f-c698-5d5a-9951-fa2b336b07cb | docs | golang | golang_sync | go119 | 13 | #### func (\*Once) [Do](https://cs.opensource.google/go/go/+/go1.19:src/sync/once.go;l=48) [¶](#Once.Do "Go to Once.Do")
```None
func (o *Once) Do(f func())
```
Do calls the function f if and only if Do is being called for the
first time for this instance of Once. In other words, given
```None
var once Once
```
if ... | large_dataset/raw/docs/golang/sync/sync_go119.md |
e217ed5f-fde9-5548-b799-584367fb3553 | docs | golang | golang_sync | go119 | 14 | #### type [Pool](https://cs.opensource.google/go/go/+/go1.19:src/sync/pool.go;l=49) [¶](#Pool "Go to Pool") added in go1.3
```None
type Pool struct {
// New optionally specifies a function to generate
// a value when Get would otherwise return nil.
// It may not be changed concurrently with calls to Get.
New func... | large_dataset/raw/docs/golang/sync/sync_go119.md |
03ef3544-6568-5e85-9d54-f380285aafae | docs | golang | golang_sync | go119 | 15 | silently shared among and potentially reused by concurrent independent
clients of a package. Pool provides a way to amortize allocation overhead
across many clients.
An example of good use of a Pool is in the fmt package, which maintains a
dynamically-sized store of temporary output buffers. The store scales under
loa... | large_dataset/raw/docs/golang/sync/sync_go119.md |
5b54cecc-60b0-5642-96c9-de86950a2007 | docs | golang | golang_sync | go119 | 16 | var bufPool = sync.Pool{
New: func() any {
// The Pool's New function should generally only return pointer
// types, since a pointer can be put into the return interface
// value without an allocation:
return new(bytes.Buffer)
},
}
// timeNow is a fake version of time.Now for tests.
func timeNow() time.Time ... | large_dataset/raw/docs/golang/sync/sync_go119.md |
a9d0af4f-cd19-5742-96a6-dc2594d8d60a | docs | golang | golang_sync | go119 | 17 | #### func (\*Pool) [Get](https://cs.opensource.google/go/go/+/go1.19:src/sync/pool.go;l=127) [¶](#Pool.Get "Go to Pool.Get") added in go1.3
```None
func (p *Pool) Get() any
```
Get selects an arbitrary item from the Pool, removes it from the
Pool, and returns it to the caller.
Get may choose to ignore the pool and tr... | large_dataset/raw/docs/golang/sync/sync_go119.md |
3910833f-982a-5a51-a3e6-eef9672bbf1d | docs | golang | golang_sync | go119 | 18 | The lock can be held by an arbitrary number of readers or a single writer.
The zero value for a RWMutex is an unlocked mutex.
A RWMutex must not be copied after first use.
If a goroutine holds a RWMutex for reading and another goroutine might
call Lock, no goroutine should expect to be able to acquire a read lock
unt... | large_dataset/raw/docs/golang/sync/sync_go119.md |
00537f59-bdde-55d0-bf94-83227aedeea6 | docs | golang | golang_sync | go119 | 19 | #### func (\*RWMutex) [Lock](https://cs.opensource.google/go/go/+/go1.19:src/sync/rwmutex.go;l=141) [¶](#RWMutex.Lock "Go to RWMutex.Lock")
```None
func (rw *RWMutex) Lock()
```
Lock locks rw for writing.
If the lock is already locked for reading or writing,
Lock blocks until the lock is available.
#### func (\*RWMu... | large_dataset/raw/docs/golang/sync/sync_go119.md |
b51a8380-453e-51ad-a6d9-a664e820bf0d | docs | golang | golang_sync | go119 | 20 | #### func (\*RWMutex) [RUnlock](https://cs.opensource.google/go/go/+/go1.19:src/sync/rwmutex.go;l=111) [¶](#RWMutex.RUnlock "Go to RWMutex.RUnlock")
```None
func (rw *RWMutex) RUnlock()
```
RUnlock undoes a single RLock call;
it does not affect other simultaneous readers.
It is a run-time error if rw is not locked fo... | large_dataset/raw/docs/golang/sync/sync_go119.md |
11d5fb3f-5400-5ebc-bdc0-7c065499fe2d | docs | golang | golang_sync | go119 | 21 | TryRLock tries to lock rw for reading and reports whether it succeeded.
Note that while correct uses of TryRLock do exist, they are rare,
and use of TryRLock is often a sign of a deeper problem
in a particular use of mutexes.
#### func (\*RWMutex) [Unlock](https://cs.opensource.google/go/go/+/go1.19:src/sync/rwmutex.... | large_dataset/raw/docs/golang/sync/sync_go119.md |
9affc6ae-210c-523c-8b93-5f98fbadbf11 | docs | golang | golang_sync | go119 | 22 | The main goroutine calls Add to set the number of
goroutines to wait for. Then each of the goroutines
runs and calls Done when finished. At the same time,
Wait can be used to block until all goroutines have finished.
A WaitGroup must not be copied after first use.
In the terminology of the Go memory model, a call to ... | large_dataset/raw/docs/golang/sync/sync_go119.md |
eb5ca207-f8e3-5cb1-8bf2-97adcd7f5d89 | docs | golang | golang_sync | go119 | 23 | defer wg.Done()
// Fetch the URL.
http.Get(url)
}(url)
}
// Wait for all HTTP fetches to complete.
wg.Wait()
}
```
Share
Format
Run
#### func (\*WaitGroup) [Add](https://cs.opensource.google/go/go/+/go1.19:src/sync/waitgroup.go;l=62) [¶](#WaitGroup.Add "Go to WaitGroup.Add")
```None
func (wg *WaitGroup... | large_dataset/raw/docs/golang/sync/sync_go119.md |
8583df7d-0aec-5abf-86fc-b19f38ed490b | docs | golang | golang_sync | go119 | 24 | new Add calls must happen after all previous Wait calls have returned.
See the WaitGroup example.
#### func (\*WaitGroup) [Done](https://cs.opensource.google/go/go/+/go1.19:src/sync/waitgroup.go;l=107) [¶](#WaitGroup.Done "Go to WaitGroup.Done")
```None
func (wg *WaitGroup) Done()
```
Done decrements the WaitGroup c... | large_dataset/raw/docs/golang/sync/sync_go119.md |
64e48bfa-9645-558f-808e-aa0698aa856a | docs | golang | golang_sync | go120 | 0 | # Golang - sync
Source: https://pkg.go.dev/sync@go1.20
Version: go1.20
## Documentation [¶](#section-documentation "Go to Documentation")
### Overview [¶](#pkg-overview "Go to Overview")
Package sync provides basic synchronization primitives such as mutual
exclusion locks. Other than the Once and WaitGroup types, m... | large_dataset/raw/docs/golang/sync/sync_go120.md |
221ae5cb-e638-5fc2-8b6e-dff6c9c2e1de | docs | golang | golang_sync | go120 | 1 | + [func (m \*Map) Delete(key any)](#Map.Delete)
+ [func (m \*Map) Load(key any) (value any, ok bool)](#Map.Load)
+ [func (m \*Map) LoadAndDelete(key any) (value any, loaded bool)](#Map.LoadAndDelete)
+ [func (m \*Map) LoadOrStore(key, value any) (actual any, loaded bool)](#Map.LoadOrStore)
+ [func (m \*Map) R... | large_dataset/raw/docs/golang/sync/sync_go120.md |
fe0c412f-2e39-5ef4-812b-0d18bf11f27d | docs | golang | golang_sync | go120 | 2 | + [func (rw \*RWMutex) RLocker() Locker](#RWMutex.RLocker)
+ [func (rw \*RWMutex) RUnlock()](#RWMutex.RUnlock)
+ [func (rw \*RWMutex) TryLock() bool](#RWMutex.TryLock)
+ [func (rw \*RWMutex) TryRLock() bool](#RWMutex.TryRLock)
+ [func (rw \*RWMutex) Unlock()](#RWMutex.Unlock)
* [type WaitGroup](#WaitGroup)
* ... | large_dataset/raw/docs/golang/sync/sync_go120.md |
f4bfc9b8-2a33-51bd-b9e3-12600bab1250 | docs | golang | golang_sync | go120 | 3 | ### Types [¶](#pkg-types "Go to Types")
#### type [Cond](https://cs.opensource.google/go/go/+/go1.20:src/sync/cond.go;l=36) [¶](#Cond "Go to Cond")
```None
type Cond struct {
// L is held while observing or changing the condition
L Locker
// contains filtered or unexported fields
}
```
Cond implements a conditio... | large_dataset/raw/docs/golang/sync/sync_go120.md |
56218aa0-bf41-56f5-8c87-29701357c474 | docs | golang | golang_sync | go120 | 4 | advanced concurrency patterns](https://blogtitle.github.io/categories/concurrency/), as well as [Bryan Mills's talk on concurrency
patterns](https://drive.google.com/file/d/1nPdvhB0PutEJzdCq5ms6UI58dp50fcAN/view).
#### func [NewCond](https://cs.opensource.google/go/go/+/go1.20:src/sync/cond.go;l=47) [¶](#NewCond "Go t... | large_dataset/raw/docs/golang/sync/sync_go120.md |
ffca19ba-d896-56f0-a3d2-57b36eddcd15 | docs | golang | golang_sync | go120 | 5 | during the call.
Signal() does not affect goroutine scheduling priority; if other goroutines
are attempting to lock c.L, they may be awoken before a "waiting" goroutine.
#### func (\*Cond) [Wait](https://cs.opensource.google/go/go/+/go1.20:src/sync/cond.go;l=66) [¶](#Cond.Wait "Go to Cond.Wait")
```None
func (c *Con... | large_dataset/raw/docs/golang/sync/sync_go120.md |
2539155c-99db-5c13-aa93-751a8c857f01 | docs | golang | golang_sync | go120 | 6 | #### type [Locker](https://cs.opensource.google/go/go/+/go1.20:src/sync/mutex.go;l=40) [¶](#Locker "Go to Locker")
```None
type Locker interface {
Lock()
Unlock()
}
```
A Locker represents an object that can be locked and unlocked.
#### type [Map](https://cs.opensource.google/go/go/+/go1.20:src/sync/map.go;l=35) [... | large_dataset/raw/docs/golang/sync/sync_go120.md |
07eef29b-aab8-5c93-abaa-630e2a31c889 | docs | golang | golang_sync | go120 | 7 | or (2) when multiple goroutines read, write, and overwrite entries for disjoint
sets of keys. In these two cases, use of a Map may significantly reduce lock
contention compared to a Go map paired with a separate Mutex or RWMutex.
The zero Map is empty and ready for use. A Map must not be copied after first use.
In th... | large_dataset/raw/docs/golang/sync/sync_go120.md |
2040b857-04bb-57a7-8752-5afa16a7c18a | docs | golang | golang_sync | go120 | 8 | #### func (\*Map) [CompareAndDelete](https://cs.opensource.google/go/go/+/go1.20:src/sync/map.go;l=406) [¶](#Map.CompareAndDelete "Go to Map.CompareAndDelete") added in go1.20
```None
func (m *Map) CompareAndDelete(key, old any) (deleted bool)
```
CompareAndDelete deletes the entry for key if its value is equal to ol... | large_dataset/raw/docs/golang/sync/sync_go120.md |
96cfe81e-9bb6-5013-b349-3efb7f9952ac | docs | golang | golang_sync | go120 | 9 | #### func (\*Map) [Delete](https://cs.opensource.google/go/go/+/go1.20:src/sync/map.go;l=296) [¶](#Map.Delete "Go to Map.Delete") added in go1.9
```None
func (m *Map) Delete(key any)
```
Delete deletes the value for a key.
#### func (\*Map) [Load](https://cs.opensource.google/go/go/+/go1.20:src/sync/map.go;l=120) [¶... | large_dataset/raw/docs/golang/sync/sync_go120.md |
b6e745e1-c854-5669-b0a9-a099ef3d3a95 | docs | golang | golang_sync | go120 | 10 | #### func (\*Map) [LoadOrStore](https://cs.opensource.google/go/go/+/go1.20:src/sync/map.go;l=203) [¶](#Map.LoadOrStore "Go to Map.LoadOrStore") added in go1.9
```None
func (m *Map) LoadOrStore(key, value any) (actual any, loaded bool)
```
LoadOrStore returns the existing value for the key if present.
Otherwise, it s... | large_dataset/raw/docs/golang/sync/sync_go120.md |
90c9e8e9-3b57-5cc2-ae81-1f00dce4ac84 | docs | golang | golang_sync | go120 | 11 | mapping for that key from any point during the Range call. Range does not
block other methods on the receiver; even f itself may call any method on m.
Range may be O(N) with the number of elements in the map even if f returns
false after a constant number of calls.
#### func (\*Map) [Store](https://cs.opensource.goog... | large_dataset/raw/docs/golang/sync/sync_go120.md |
3fa53007-0f6f-521a-9fbf-a3e2caa69f65 | docs | golang | golang_sync | go120 | 12 | #### type [Mutex](https://cs.opensource.google/go/go/+/go1.20:src/sync/mutex.go;l=34) [¶](#Mutex "Go to Mutex")
```None
type Mutex struct {
// contains filtered or unexported fields
}
```
A Mutex is a mutual exclusion lock.
The zero value for a Mutex is an unlocked mutex.
A Mutex must not be copied after first use.... | large_dataset/raw/docs/golang/sync/sync_go120.md |
41c9409e-9612-5146-93d5-82785405ec81 | docs | golang | golang_sync | go120 | 13 | #### func (\*Mutex) [TryLock](https://cs.opensource.google/go/go/+/go1.20:src/sync/mutex.go;l=98) [¶](#Mutex.TryLock "Go to Mutex.TryLock") added in go1.18
```None
func (m *Mutex) TryLock() bool
```
TryLock tries to lock m and reports whether it succeeded.
Note that while correct uses of TryLock do exist, they are r... | large_dataset/raw/docs/golang/sync/sync_go120.md |
655eac6a-4f7e-5038-b416-042b149de182 | docs | golang | golang_sync | go120 | 14 | #### type [Once](https://cs.opensource.google/go/go/+/go1.20:src/sync/once.go;l=18) [¶](#Once "Go to Once")
```None
type Once struct {
// contains filtered or unexported fields
}
```
Once is an object that will perform exactly one action.
A Once must not be copied after first use.
In the terminology of the Go memo... | large_dataset/raw/docs/golang/sync/sync_go120.md |
f056b9a5-54fd-5f79-a0b9-32eaf4923e20 | docs | golang | golang_sync | go120 | 15 | Do calls the function f if and only if Do is being called for the
first time for this instance of Once. In other words, given
```None
var once Once
```
if once.Do(f) is called multiple times, only the first call will invoke f,
even if f has a different value in each invocation. A new instance of
Once is required for ... | large_dataset/raw/docs/golang/sync/sync_go120.md |
b74f2009-98ca-584a-800c-3be60439afbe | docs | golang | golang_sync | go120 | 16 | #### type [Pool](https://cs.opensource.google/go/go/+/go1.20:src/sync/pool.go;l=49) [¶](#Pool "Go to Pool") added in go1.3
```None
type Pool struct {
// New optionally specifies a function to generate
// a value when Get would otherwise return nil.
// It may not be changed concurrently with calls to Get.
New func... | large_dataset/raw/docs/golang/sync/sync_go120.md |
026fe0e3-7332-50dd-bfba-eff2d5fbe5e4 | docs | golang | golang_sync | go120 | 17 | silently shared among and potentially reused by concurrent independent
clients of a package. Pool provides a way to amortize allocation overhead
across many clients.
An example of good use of a Pool is in the fmt package, which maintains a
dynamically-sized store of temporary output buffers. The store scales under
loa... | large_dataset/raw/docs/golang/sync/sync_go120.md |
fe415a2a-52d0-53cf-b98a-c83e303d47b1 | docs | golang | golang_sync | go120 | 18 | var bufPool = sync.Pool{
New: func() any {
// The Pool's New function should generally only return pointer
// types, since a pointer can be put into the return interface
// value without an allocation:
return new(bytes.Buffer)
},
}
// timeNow is a fake version of time.Now for tests.
func timeNow() time.Time ... | large_dataset/raw/docs/golang/sync/sync_go120.md |
1f7a8b0d-cf1b-5a39-8657-a09ff678b68d | docs | golang | golang_sync | go120 | 19 | #### func (\*Pool) [Get](https://cs.opensource.google/go/go/+/go1.20:src/sync/pool.go;l=127) [¶](#Pool.Get "Go to Pool.Get") added in go1.3
```None
func (p *Pool) Get() any
```
Get selects an arbitrary item from the Pool, removes it from the
Pool, and returns it to the caller.
Get may choose to ignore the pool and tr... | large_dataset/raw/docs/golang/sync/sync_go120.md |
93e09d0d-4167-5cd6-912b-68c385aec972 | docs | golang | golang_sync | go120 | 20 | The lock can be held by an arbitrary number of readers or a single writer.
The zero value for a RWMutex is an unlocked mutex.
A RWMutex must not be copied after first use.
If a goroutine holds a RWMutex for reading and another goroutine might
call Lock, no goroutine should expect to be able to acquire a read lock
unt... | large_dataset/raw/docs/golang/sync/sync_go120.md |
35d055ad-5b29-5ed2-b01f-709c88ef490f | docs | golang | golang_sync | go120 | 21 | #### func (\*RWMutex) [Lock](https://cs.opensource.google/go/go/+/go1.20:src/sync/rwmutex.go;l=141) [¶](#RWMutex.Lock "Go to RWMutex.Lock")
```None
func (rw *RWMutex) Lock()
```
Lock locks rw for writing.
If the lock is already locked for reading or writing,
Lock blocks until the lock is available.
#### func (\*RWMu... | large_dataset/raw/docs/golang/sync/sync_go120.md |
5ff31024-3592-5d20-9e8d-84f6bb8f5065 | docs | golang | golang_sync | go120 | 22 | #### func (\*RWMutex) [RUnlock](https://cs.opensource.google/go/go/+/go1.20:src/sync/rwmutex.go;l=111) [¶](#RWMutex.RUnlock "Go to RWMutex.RUnlock")
```None
func (rw *RWMutex) RUnlock()
```
RUnlock undoes a single RLock call;
it does not affect other simultaneous readers.
It is a run-time error if rw is not locked fo... | large_dataset/raw/docs/golang/sync/sync_go120.md |
67d8f400-a833-554e-be79-1cf383b725bb | docs | golang | golang_sync | go120 | 23 | TryRLock tries to lock rw for reading and reports whether it succeeded.
Note that while correct uses of TryRLock do exist, they are rare,
and use of TryRLock is often a sign of a deeper problem
in a particular use of mutexes.
#### func (\*RWMutex) [Unlock](https://cs.opensource.google/go/go/+/go1.20:src/sync/rwmutex.... | large_dataset/raw/docs/golang/sync/sync_go120.md |
e4a7d07b-b898-5e8d-8a8b-bddc628a0d98 | docs | golang | golang_sync | go120 | 24 | The main goroutine calls Add to set the number of
goroutines to wait for. Then each of the goroutines
runs and calls Done when finished. At the same time,
Wait can be used to block until all goroutines have finished.
A WaitGroup must not be copied after first use.
In the terminology of the Go memory model, a call to ... | large_dataset/raw/docs/golang/sync/sync_go120.md |
cac485af-6161-579a-a48a-6642963cac29 | docs | golang | golang_sync | go120 | 25 | defer wg.Done()
// Fetch the URL.
http.Get(url)
}(url)
}
// Wait for all HTTP fetches to complete.
wg.Wait()
}
```
Share
Format
Run
#### func (\*WaitGroup) [Add](https://cs.opensource.google/go/go/+/go1.20:src/sync/waitgroup.go;l=43) [¶](#WaitGroup.Add "Go to WaitGroup.Add")
```None
func (wg *WaitGroup... | large_dataset/raw/docs/golang/sync/sync_go120.md |
33c660ed-d2d4-512d-b968-a3ec686f4d08 | docs | golang | golang_sync | go120 | 26 | new Add calls must happen after all previous Wait calls have returned.
See the WaitGroup example.
#### func (\*WaitGroup) [Done](https://cs.opensource.google/go/go/+/go1.20:src/sync/waitgroup.go;l=86) [¶](#WaitGroup.Done "Go to WaitGroup.Done")
```None
func (wg *WaitGroup) Done()
```
Done decrements the WaitGroup co... | large_dataset/raw/docs/golang/sync/sync_go120.md |
18b62289-71ff-50cb-979f-6bd8fbf9649d | docs | golang | golang_sync | go1210 | 0 | # Golang - sync
Source: https://pkg.go.dev/sync@go1.21.0
Version: go1.21.0
## Documentation [¶](#section-documentation "Go to Documentation")
### Overview [¶](#pkg-overview "Go to Overview")
Package sync provides basic synchronization primitives such as mutual
exclusion locks. Other than the Once and WaitGroup type... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
afea6343-42d6-599d-8ae2-27c025a5879a | docs | golang | golang_sync | go1210 | 1 | * + [func (m \*Map) CompareAndDelete(key, old any) (deleted bool)](#Map.CompareAndDelete)
+ [func (m \*Map) CompareAndSwap(key, old, new any) bool](#Map.CompareAndSwap)
+ [func (m \*Map) Delete(key any)](#Map.Delete)
+ [func (m \*Map) Load(key any) (value any, ok bool)](#Map.Load)
+ [func (m \*Map) LoadAndDelet... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
ea9c3ae3-974f-59b5-a78a-23286a472139 | docs | golang | golang_sync | go1210 | 2 | * [type RWMutex](#RWMutex)
* + [func (rw \*RWMutex) Lock()](#RWMutex.Lock)
+ [func (rw \*RWMutex) RLock()](#RWMutex.RLock)
+ [func (rw \*RWMutex) RLocker() Locker](#RWMutex.RLocker)
+ [func (rw \*RWMutex) RUnlock()](#RWMutex.RUnlock)
+ [func (rw \*RWMutex) TryLock() bool](#RWMutex.TryLock)
+ [func (rw \*RWMut... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
c9c0eab7-8599-55bd-b7d9-fe1b974f6d87 | docs | golang | golang_sync | go1210 | 3 | ### Variables [¶](#pkg-variables "Go to Variables")
This section is empty.
### Functions [¶](#pkg-functions "Go to Functions")
#### func [OnceFunc](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/oncefunc.go;l=11) [¶](#OnceFunc "Go to OnceFunc") added in go1.21.0
```None
func OnceFunc(f func()) func()
```
O... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
7ed87422-b528-5c21-85fb-75a1347ee322 | docs | golang | golang_sync | go1210 | 4 | #### func [OnceValues](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/oncefunc.go;l=72) [¶](#OnceValues "Go to OnceValues") added in go1.21.0
```None
func OnceValues[T1, T2 any](f func() (T1, T2)) func() (T1, T2)
```
OnceValues returns a function that invokes f only once and returns the values
returned by f. ... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
64849456-7235-5920-a27c-445e3e51ce8d | docs | golang | golang_sync | go1210 | 5 | when calling the Wait method.
A Cond must not be copied after first use.
In the terminology of the Go memory model, Cond arranges that
a call to Broadcast or Signal “synchronizes before” any Wait call
that it unblocks.
For many simple use cases, users will be better off using channels than a
Cond (Broadcast correspo... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
8d19eae5-ea56-5d01-9c0b-2c24dbdca05b | docs | golang | golang_sync | go1210 | 6 | #### func (\*Cond) [Broadcast](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/cond.go;l=90) [¶](#Cond.Broadcast "Go to Cond.Broadcast")
```None
func (c *Cond) Broadcast()
```
Broadcast wakes all goroutines waiting on c.
It is allowed but not required for the caller to hold c.L
during the call.
#### func (\*... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
ddf9f62a-b949-5d15-92aa-726803b833e5 | docs | golang | golang_sync | go1210 | 7 | of the calling goroutine. After later resuming execution,
Wait locks c.L before returning. Unlike in other systems,
Wait cannot return unless awoken by Broadcast or Signal.
Because c.L is not locked while Wait is waiting, the caller
typically cannot assume that the condition is true when
Wait returns. Instead, the cal... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
56d751ff-6b23-5046-bc18-6dbc236fb1e8 | docs | golang | golang_sync | go1210 | 8 | by multiple goroutines without additional locking or coordination.
Loads, stores, and deletes run in amortized constant time.
The Map type is specialized. Most code should use a plain Go map instead,
with separate locking or coordination, for better type safety and to make it
easier to maintain other invariants along ... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
ebee8039-3701-5bfc-9907-9860f3d91777 | docs | golang | golang_sync | go1210 | 9 | read and write operations are defined as follows.
Load, LoadAndDelete, LoadOrStore, Swap, CompareAndSwap, and CompareAndDelete
are read operations; Delete, LoadAndDelete, Store, and Swap are write operations;
LoadOrStore is a write operation when it returns loaded set to false;
CompareAndSwap is a write operation when ... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
2d50597a-c6be-5def-a83c-e60df826b200 | docs | golang | golang_sync | go1210 | 10 | #### func (\*Map) [CompareAndSwap](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/map.go;l=374) [¶](#Map.CompareAndSwap "Go to Map.CompareAndSwap") added in go1.20
```None
func (m *Map) CompareAndSwap(key, old, new any) bool
```
CompareAndSwap swaps the old and new values for key
if the value stored in the ma... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
b21a624c-2fe7-5164-8e57-0d1acf95e857 | docs | golang | golang_sync | go1210 | 11 | #### func (\*Map) [LoadAndDelete](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/map.go;l=272) [¶](#Map.LoadAndDelete "Go to Map.LoadAndDelete") added in go1.15
```None
func (m *Map) LoadAndDelete(key any) (value any, loaded bool)
```
LoadAndDelete deletes the value for a key, returning the previous value if ... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
040d5a42-b445-5d2f-b3b0-e6930637905a | docs | golang | golang_sync | go1210 | 12 | #### func (\*Map) [Range](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/map.go;l=449) [¶](#Map.Range "Go to Map.Range") added in go1.9
```None
func (m *Map) Range(f func(key, value any) bool)
```
Range calls f sequentially for each key and value present in the map.
If f returns false, range stops the iterati... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
5880d7f6-9461-55e2-9c52-e60f522a5422 | docs | golang | golang_sync | go1210 | 13 | #### func (\*Map) [Store](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/map.go;l=154) [¶](#Map.Store "Go to Map.Store") added in go1.9
```None
func (m *Map) Store(key, value any)
```
Store sets the value for a key.
#### func (\*Map) [Swap](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/map.go;l=330)... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
fa81a8db-ecd3-5170-9e86-840bc23204ee | docs | golang | golang_sync | go1210 | 14 | A successful call to TryLock is equivalent to a call to Lock.
A failed call to TryLock does not establish any “synchronizes before”
relation at all.
#### func (\*Mutex) [Lock](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/mutex.go;l=81) [¶](#Mutex.Lock "Go to Mutex.Lock")
```None
func (m *Mutex) Lock()
```
... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
f1d91e78-84ec-52bb-962b-a3088217c8d2 | docs | golang | golang_sync | go1210 | 15 | #### func (\*Mutex) [Unlock](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/mutex.go;l=212) [¶](#Mutex.Unlock "Go to Mutex.Unlock")
```None
func (m *Mutex) Unlock()
```
Unlock unlocks m.
It is a run-time error if m is not locked on entry to Unlock.
A locked Mutex is not associated with a particular goroutine... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
c2d0432d-4235-5383-9692-d492fdefa160 | docs | golang | golang_sync | go1210 | 16 | done := make(chan bool)
for i := 0; i < 10; i++ {
go func() {
once.Do(onceBody)
done <- true
}()
}
for i := 0; i < 10; i++ {
<-done
}
}
```
```None
Output:
Only once
```
Share
Format
Run
#### func (\*Once) [Do](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/once.go;l=48) [¶](#Once.Do "Go to... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
8d2e134d-9185-5f44-99c0-caa7bfdd437c | docs | golang | golang_sync | go1210 | 17 | Because no call to Do returns until the one call to f returns, if f causes
Do to be called, it will deadlock.
If f panics, Do considers it to have returned; future calls of Do return
without calling f.
#### type [Pool](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/pool.go;l=49) [¶](#Pool "Go to Pool") added ... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
93d447d9-7f25-502d-b221-1a41339db7ff | docs | golang | golang_sync | go1210 | 18 | relieving pressure on the garbage collector. That is, it makes it easy to
build efficient, thread-safe free lists. However, it is not suitable for all
free lists.
An appropriate use of a Pool is to manage a group of temporary items
silently shared among and potentially reused by concurrent independent
clients of a pac... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
4be84bd3-15bb-5700-8b86-d5eeed11aa0d | docs | golang | golang_sync | go1210 | 19 | a call to Get returning that same value x.
Similarly, a call to New returning x “synchronizes before”
a call to Get returning that same value x.
Example [¶](#example-Pool "Go to Example")
```None
package main
import (
"bytes"
"io"
"os"
"sync"
"time"
)
var bufPool = sync.Pool{
New: func() any {
// The Pool's... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
0d211121-c005-5fde-9380-300bb3567d52 | docs | golang | golang_sync | go1210 | 20 | 2006-01-02T15:04:05Z path=/search?q=flowers
```
Share
Format
Run
#### func (\*Pool) [Get](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/pool.go;l=127) [¶](#Pool.Get "Go to Pool.Get") added in go1.3
```None
func (p *Pool) Get() any
```
Get selects an arbitrary item from the Pool, removes it from the
Pool, a... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
81d8e529-248d-5694-9a5a-ddf14eadb667 | docs | golang | golang_sync | go1210 | 21 | #### type [RWMutex](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/rwmutex.go;l=36) [¶](#RWMutex "Go to RWMutex")
```None
type RWMutex struct {
// contains filtered or unexported fields
}
```
A RWMutex is a reader/writer mutual exclusion lock.
The lock can be held by an arbitrary number of readers or a singl... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
f8542b27-dc25-5a7f-b6f9-e5a9b52121a6 | docs | golang | golang_sync | go1210 | 22 | the n'th call to Unlock “synchronizes before” that call to RLock,
and the corresponding call to RUnlock “synchronizes before”
the n+1'th call to Lock.
#### func (\*RWMutex) [Lock](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/rwmutex.go;l=141) [¶](#RWMutex.Lock "Go to RWMutex.Lock")
```None
func (rw *RWMutex... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
4b01a8de-eb1f-5ce1-a03b-14c8a4f89ee7 | docs | golang | golang_sync | go1210 | 23 | #### func (\*RWMutex) [RLocker](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/rwmutex.go;l=237) [¶](#RWMutex.RLocker "Go to RWMutex.RLocker")
```None
func (rw *RWMutex) RLocker() Locker
```
RLocker returns a Locker interface that implements
the Lock and Unlock methods by calling rw.RLock and rw.RUnlock.
###... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
9a3f66f8-1a65-517c-9f00-d33878f7c615 | docs | golang | golang_sync | go1210 | 24 | and use of TryLock is often a sign of a deeper problem
in a particular use of mutexes.
#### func (\*RWMutex) [TryRLock](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/rwmutex.go;l=84) [¶](#RWMutex.TryRLock "Go to RWMutex.TryRLock") added in go1.18
```None
func (rw *RWMutex) TryRLock() bool
```
TryRLock tries... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
a86e0459-402c-5b2b-96c1-762cac016d3e | docs | golang | golang_sync | go1210 | 25 | #### type [WaitGroup](https://cs.opensource.google/go/go/+/go1.21.0:src/sync/waitgroup.go;l=23) [¶](#WaitGroup "Go to WaitGroup")
```None
type WaitGroup struct {
// contains filtered or unexported fields
}
```
A WaitGroup waits for a collection of goroutines to finish.
The main goroutine calls Add to set the number ... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
eb046164-2381-5d32-aff3-f38f82c71cc3 | docs | golang | golang_sync | go1210 | 26 | "http://www.golang.org/",
"http://www.google.com/",
"http://www.example.com/",
}
for _, url := range urls {
// Increment the WaitGroup counter.
wg.Add(1)
// Launch a goroutine to fetch the URL.
go func(url string) {
// Decrement the counter when the goroutine completes.
defer wg.Done()
// Fetch... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
b760430f-fb01-5159-b503-686281396679 | docs | golang | golang_sync | go1210 | 27 | positive delta that start when the counter is greater than zero, may happen
at any time.
Typically this means the calls to Add should execute before the statement
creating the goroutine or other event to be waited for.
If a WaitGroup is reused to wait for several independent sets of events,
new Add calls must happen af... | large_dataset/raw/docs/golang/sync/sync_go1210.md |
e73b3d4e-9041-570e-b5ff-12ca2e31c13d | docs | golang | golang_sync | go1220 | 0 | # Golang - sync
Source: https://pkg.go.dev/sync@go1.22.0
Version: go1.22.0
## Documentation [¶](#section-documentation "Go to Documentation")
### Overview [¶](#pkg-overview "Go to Overview")
Package sync provides basic synchronization primitives such as mutual
exclusion locks. Other than the Once and WaitGroup type... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
bb806ddb-0f4e-5c2f-b8b0-041cd4a73e14 | docs | golang | golang_sync | go1220 | 1 | * + [func (m \*Map) CompareAndDelete(key, old any) (deleted bool)](#Map.CompareAndDelete)
+ [func (m \*Map) CompareAndSwap(key, old, new any) bool](#Map.CompareAndSwap)
+ [func (m \*Map) Delete(key any)](#Map.Delete)
+ [func (m \*Map) Load(key any) (value any, ok bool)](#Map.Load)
+ [func (m \*Map) LoadAndDelet... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
07d6fff9-e544-5a47-80a2-7e1aec123caf | docs | golang | golang_sync | go1220 | 2 | * [type RWMutex](#RWMutex)
* + [func (rw \*RWMutex) Lock()](#RWMutex.Lock)
+ [func (rw \*RWMutex) RLock()](#RWMutex.RLock)
+ [func (rw \*RWMutex) RLocker() Locker](#RWMutex.RLocker)
+ [func (rw \*RWMutex) RUnlock()](#RWMutex.RUnlock)
+ [func (rw \*RWMutex) TryLock() bool](#RWMutex.TryLock)
+ [func (rw \*RWMut... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
684469da-3e50-5b89-b3a6-91d6985d34ad | docs | golang | golang_sync | go1220 | 3 | ### Variables [¶](#pkg-variables "Go to Variables")
This section is empty.
### Functions [¶](#pkg-functions "Go to Functions")
#### func [OnceFunc](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/oncefunc.go;l=11) [¶](#OnceFunc "Go to OnceFunc") added in go1.21.0
```None
func OnceFunc(f func()) func()
```
O... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
ceb9a1bb-c39c-5bfc-b288-937277ec293e | docs | golang | golang_sync | go1220 | 4 | #### func [OnceValues](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/oncefunc.go;l=74) [¶](#OnceValues "Go to OnceValues") added in go1.21.0
```None
func OnceValues[T1, T2 any](f func() (T1, T2)) func() (T1, T2)
```
OnceValues returns a function that invokes f only once and returns the values
returned by f. ... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
5d717e6d-33d3-5117-804c-2cc27ad609c0 | docs | golang | golang_sync | go1220 | 5 | when calling the Wait method.
A Cond must not be copied after first use.
In the terminology of the Go memory model, Cond arranges that
a call to Broadcast or Signal “synchronizes before” any Wait call
that it unblocks.
For many simple use cases, users will be better off using channels than a
Cond (Broadcast correspo... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
68d08cd0-4771-5280-a638-723373b1b9af | docs | golang | golang_sync | go1220 | 6 | #### func (\*Cond) [Broadcast](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/cond.go;l=90) [¶](#Cond.Broadcast "Go to Cond.Broadcast")
```None
func (c *Cond) Broadcast()
```
Broadcast wakes all goroutines waiting on c.
It is allowed but not required for the caller to hold c.L
during the call.
#### func (\*... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
5b2c8a3f-c6c8-5caf-a176-5b571b86f8f4 | docs | golang | golang_sync | go1220 | 7 | of the calling goroutine. After later resuming execution,
Wait locks c.L before returning. Unlike in other systems,
Wait cannot return unless awoken by Broadcast or Signal.
Because c.L is not locked while Wait is waiting, the caller
typically cannot assume that the condition is true when
Wait returns. Instead, the cal... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
c0e81afe-6e26-520f-87ae-34e919139772 | docs | golang | golang_sync | go1220 | 8 | Loads, stores, and deletes run in amortized constant time.
The Map type is specialized. Most code should use a plain Go map instead,
with separate locking or coordination, for better type safety and to make it
easier to maintain other invariants along with the map content.
The Map type is optimized for two common use... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
b5af8143-8a6e-5cb2-9114-0f0546cf9077 | docs | golang | golang_sync | go1220 | 9 | Load, LoadAndDelete, LoadOrStore, Swap, CompareAndSwap, and CompareAndDelete
are read operations; Delete, LoadAndDelete, Store, and Swap are write operations;
LoadOrStore is a write operation when it returns loaded set to false;
CompareAndSwap is a write operation when it returns swapped set to true;
and CompareAndDele... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
b25427c9-6cec-5f7d-930b-2c4258c6a626 | docs | golang | golang_sync | go1220 | 10 | #### func (\*Map) [CompareAndSwap](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/map.go;l=374) [¶](#Map.CompareAndSwap "Go to Map.CompareAndSwap") added in go1.20
```None
func (m *Map) CompareAndSwap(key, old, new any) bool
```
CompareAndSwap swaps the old and new values for key
if the value stored in the ma... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
504b5c73-49f7-5fe4-b361-f5446e35b45c | docs | golang | golang_sync | go1220 | 11 | #### func (\*Map) [LoadAndDelete](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/map.go;l=272) [¶](#Map.LoadAndDelete "Go to Map.LoadAndDelete") added in go1.15
```None
func (m *Map) LoadAndDelete(key any) (value any, loaded bool)
```
LoadAndDelete deletes the value for a key, returning the previous value if ... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
cdfbaf4c-6188-568d-8cb9-7a12bf1d619b | docs | golang | golang_sync | go1220 | 12 | #### func (\*Map) [Range](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/map.go;l=449) [¶](#Map.Range "Go to Map.Range") added in go1.9
```None
func (m *Map) Range(f func(key, value any) bool)
```
Range calls f sequentially for each key and value present in the map.
If f returns false, range stops the iterati... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
6d598e5f-6f86-5e38-b872-47cdfda156a4 | docs | golang | golang_sync | go1220 | 13 | #### func (\*Map) [Store](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/map.go;l=154) [¶](#Map.Store "Go to Map.Store") added in go1.9
```None
func (m *Map) Store(key, value any)
```
Store sets the value for a key.
#### func (\*Map) [Swap](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/map.go;l=330)... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
52edb21c-fbd0-53a3-a7db-fe1f03216475 | docs | golang | golang_sync | go1220 | 14 | A successful call to TryLock is equivalent to a call to Lock.
A failed call to TryLock does not establish any “synchronizes before”
relation at all.
#### func (\*Mutex) [Lock](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/mutex.go;l=81) [¶](#Mutex.Lock "Go to Mutex.Lock")
```None
func (m *Mutex) Lock()
```
... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
a16edd91-cdad-536a-bd5f-8c0274049cbc | docs | golang | golang_sync | go1220 | 15 | #### func (\*Mutex) [Unlock](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/mutex.go;l=212) [¶](#Mutex.Unlock "Go to Mutex.Unlock")
```None
func (m *Mutex) Unlock()
```
Unlock unlocks m.
It is a run-time error if m is not locked on entry to Unlock.
A locked Mutex is not associated with a particular goroutine... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
dd39cfc8-8227-5668-8236-49351f459039 | docs | golang | golang_sync | go1220 | 16 | done := make(chan bool)
for i := 0; i < 10; i++ {
go func() {
once.Do(onceBody)
done <- true
}()
}
for i := 0; i < 10; i++ {
<-done
}
}
```
```None
Output:
Only once
```
Share
Format
Run
#### func (\*Once) [Do](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/once.go;l=48) [¶](#Once.Do "Go to... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
11d10ef0-aa0d-5b05-ac39-7c081c40c73d | docs | golang | golang_sync | go1220 | 17 | Because no call to Do returns until the one call to f returns, if f causes
Do to be called, it will deadlock.
If f panics, Do considers it to have returned; future calls of Do return
without calling f.
#### type [Pool](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/pool.go;l=49) [¶](#Pool "Go to Pool") added ... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
821a54e2-d266-5ee2-bc79-2e2ce983dcb9 | docs | golang | golang_sync | go1220 | 18 | relieving pressure on the garbage collector. That is, it makes it easy to
build efficient, thread-safe free lists. However, it is not suitable for all
free lists.
An appropriate use of a Pool is to manage a group of temporary items
silently shared among and potentially reused by concurrent independent
clients of a pac... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
e76b92a0-7a1d-5310-9a23-2dfd67f4835d | docs | golang | golang_sync | go1220 | 19 | a call to Get returning that same value x.
Similarly, a call to New returning x “synchronizes before”
a call to Get returning that same value x.
Example [¶](#example-Pool "Go to Example")
```None
package main
import (
"bytes"
"io"
"os"
"sync"
"time"
)
var bufPool = sync.Pool{
New: func() any {
// The Pool's... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
fb46263f-5872-5cb0-a05c-a9e0db9aeb4c | docs | golang | golang_sync | go1220 | 20 | 2006-01-02T15:04:05Z path=/search?q=flowers
```
Share
Format
Run
#### func (\*Pool) [Get](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/pool.go;l=128) [¶](#Pool.Get "Go to Pool.Get") added in go1.3
```None
func (p *Pool) Get() any
```
Get selects an arbitrary item from the Pool, removes it from the
Pool, a... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
e6fa88a1-0971-56cb-b57a-a8b4ce205704 | docs | golang | golang_sync | go1220 | 21 | #### type [RWMutex](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/rwmutex.go;l=35) [¶](#RWMutex "Go to RWMutex")
```None
type RWMutex struct {
// contains filtered or unexported fields
}
```
A RWMutex is a reader/writer mutual exclusion lock.
The lock can be held by an arbitrary number of readers or a singl... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
3ad339d2-38f4-5e5a-b87e-d8468caaef5c | docs | golang | golang_sync | go1220 | 22 | and the corresponding call to RUnlock “synchronizes before”
the n+1'th call to Lock.
#### func (\*RWMutex) [Lock](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/rwmutex.go;l=140) [¶](#RWMutex.Lock "Go to RWMutex.Lock")
```None
func (rw *RWMutex) Lock()
```
Lock locks rw for writing.
If the lock is already lo... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
e8b8f752-a4bb-555a-a515-1bb5e2fb1f63 | docs | golang | golang_sync | go1220 | 23 | the Lock and Unlock methods by calling rw.RLock and rw.RUnlock.
#### func (\*RWMutex) [RUnlock](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/rwmutex.go;l=110) [¶](#RWMutex.RUnlock "Go to RWMutex.RUnlock")
```None
func (rw *RWMutex) RUnlock()
```
RUnlock undoes a single RLock call;
it does not affect other ... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
9bd87e8c-cbb2-5be1-a6f2-1ac8fecfb949 | docs | golang | golang_sync | go1220 | 24 | #### func (\*RWMutex) [TryRLock](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/rwmutex.go;l=83) [¶](#RWMutex.TryRLock "Go to RWMutex.TryRLock") added in go1.18
```None
func (rw *RWMutex) TryRLock() bool
```
TryRLock tries to lock rw for reading and reports whether it succeeded.
Note that while correct uses ... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
5d8ded2b-c4f9-5e5d-b42f-18d42071fcd5 | docs | golang | golang_sync | go1220 | 25 | #### type [WaitGroup](https://cs.opensource.google/go/go/+/go1.22.0:src/sync/waitgroup.go;l=23) [¶](#WaitGroup "Go to WaitGroup")
```None
type WaitGroup struct {
// contains filtered or unexported fields
}
```
A WaitGroup waits for a collection of goroutines to finish.
The main goroutine calls Add to set the number ... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
440d01fc-8a47-53f0-b382-ef35c8dabe11 | docs | golang | golang_sync | go1220 | 26 | "http://www.golang.org/",
"http://www.google.com/",
"http://www.example.com/",
}
for _, url := range urls {
// Increment the WaitGroup counter.
wg.Add(1)
// Launch a goroutine to fetch the URL.
go func(url string) {
// Decrement the counter when the goroutine completes.
defer wg.Done()
// Fetch... | large_dataset/raw/docs/golang/sync/sync_go1220.md |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.