func (s *Session) SetSafe(safe *Safe) {
	s.m.Lock()
	s.safeOp = nil
	s.ensureSafe(safe)
	s.m.Unlock()
}
func (s *Session) SetSafe(safe *Safe) {
	s.m.Lock()
	s.safeOp = nil
	s.ensureSafe(safe)
	s.m.Unlock()
}
func ( s * Session ) SetSafe ( safe * Safe ) { s . m . Lock ( ) s . safeOp = nil s . ensureSafe ( safe ) s . m . Unlock ( ) }
// SetSafe changes the session safety mode.
//
// If the safe parameter is nil, the session is put in unsafe mode, and writes
// become fire-and-forget, without error checking.  The unsafe mode is faster
// since operations won't hold on waiting for a confirmation.
//
// If the safe parameter is not nil, any changing query (insert, update, ...)
// will be followed by a getLastError command with the specified parameters,
// to ensure the request was correctly processed.
//
// The safe.W parameter determines how many servers should confirm a write
// before the operation is considered successful.  If set to 0 or 1, the
// command will return as soon as the primary is done with the request.
// If safe.WTimeout is greater than zero, it determines how many milliseconds
// to wait for the safe.W servers to respond before returning an error.
//
// Starting with MongoDB 2.0.0 the safe.WMode parameter can be used instead
// of W to request for richer semantics. If set to "majority" the server will
// wait for a majority of members from the replica set to respond before
// returning. Custom modes may also be defined within the server to create
// very detailed placement schemas. See the data awareness documentation in
// the links below for more details (note that MongoDB internally reuses the
// "w" field name for WMode).
//
// If safe.FSync is true and journaling is disabled, the servers will be
// forced to sync all files to disk immediately before returning. If the
// same option is true but journaling is enabled, the server will instead
// await for the next group commit before returning.
//
// Since MongoDB 2.0.0, the safe.J option can also be used instead of FSync
// to force the server to wait for a group commit in case journaling is
// enabled. The option has no effect if the server has journaling disabled.
//
// For example, the following statement will make the session check for
// errors, without imposing further constraints:
//
//     session.SetSafe(&mgo.Safe{})
//
// The following statement will force the server to wait for a majority of
// members of a replica set to return (MongoDB 2.0+ only):
//
//     session.SetSafe(&mgo.Safe{WMode: "majority"})
//
// The following statement, on the other hand, ensures that at least two
// servers have flushed the change to disk before confirming the success
// of operations:
//
//     session.EnsureSafe(&mgo.Safe{W: 2, FSync: true})
//
// The following statement, on the other hand, disables the verification
// of errors entirely:
//
//     session.SetSafe(nil)
//
// See also the EnsureSafe method.
//
// Relevant documentation:
//
//     http://www.mongodb.org/display/DOCS/getLastError+Command
//     http://www.mongodb.org/display/DOCS/Verifying+Propagation+of+Writes+with+getLastError
//     http://www.mongodb.org/display/DOCS/Data+Center+Awareness
//
SetSafe changes the session safety mode . If the safe parameter is nil the session is put in unsafe mode and writes become fire - and - forget without error checking . The unsafe mode is faster since operations won t hold on waiting for a confirmation . If the safe parameter is not nil any changing query ( insert update ... ) will be followed by a getLastError command with the specified parameters to ensure the request was correctly processed . The safe . W parameter determines how many servers should confirm a write before the operation is considered successful . If set to 0 or 1 the command will return as soon as the primary is done with the request . If safe . WTimeout is greater than zero it determines how many milliseconds to wait for the safe . W servers to respond before returning an error . Starting with MongoDB 2 . 0 . 0 the safe . WMode parameter can be used instead of W to request for richer semantics . If set to majority the server will wait for a majority of members from the replica set to respond before returning . Custom modes may also be defined within the server to create very detailed placement schemas . See the data awareness documentation in the links below for more details ( note that MongoDB internally reuses the w field name for WMode ) . If safe . FSync is true and journaling is disabled the servers will be forced to sync all files to disk immediately before returning . If the same option is true but journaling is enabled the server will instead await for the next group commit before returning . Since MongoDB 2 . 0 . 0 the safe . J option can also be used instead of FSync to force the server to wait for a group commit in case journaling is enabled . The option has no effect if the server has journaling disabled . For example the following statement will make the session check for errors without imposing further constraints : session . SetSafe ( &mgo . Safe {} ) The following statement will force the server to wait for a majority of members of a replica set to return ( MongoDB 2 . 0 + only ) : session . SetSafe ( &mgo . Safe { WMode : majority } ) The following statement on the other hand ensures that at least two servers have flushed the change to disk before confirming the success of operations : session . EnsureSafe ( &mgo . Safe { W : 2 FSync : true } ) The following statement on the other hand disables the verification of errors entirely : session . SetSafe ( nil ) See also the EnsureSafe method . Relevant documentation : http : // www . mongodb . org / display / DOCS / getLastError + Command http : // www . mongodb . org / display / DOCS / Verifying + Propagation + of + Writes + with + getLastError http : // www . mongodb . org / display / DOCS / Data + Center + Awareness