AcquireFile returns a (pooled) File object and applies the provided SetFileFunc functions to it.
(setter ...SetFileFunc)
| 1035 | |
| 1036 | // AcquireFile returns a (pooled) File object and applies the provided SetFileFunc functions to it. |
| 1037 | func AcquireFile(setter ...SetFileFunc) *File { |
| 1038 | fv := filePool.Get() |
| 1039 | if fv != nil { |
| 1040 | f, ok := fv.(*File) |
| 1041 | if !ok { |
| 1042 | panic(errFileTypeAssertion) |
| 1043 | } |
| 1044 | for _, v := range setter { |
| 1045 | v(f) |
| 1046 | } |
| 1047 | return f |
| 1048 | } |
| 1049 | f := &File{} |
| 1050 | for _, v := range setter { |
| 1051 | v(f) |
| 1052 | } |
| 1053 | return f |
| 1054 | } |
| 1055 | |
| 1056 | // ReleaseFile returns the File object to the pool. |
| 1057 | // Do not use the released File afterward to avoid data races. |