mirror of
				https://github.com/TeaOSLab/EdgeNode.git
				synced 2025-11-04 16:00:25 +08:00 
			
		
		
		
	
		
			
	
	
		
			22 lines
		
	
	
		
			508 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			22 lines
		
	
	
		
			508 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								package compressions
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import (
							 | 
						||
| 
								 | 
							
									"github.com/TeaOSLab/EdgeNode/internal/utils"
							 | 
						||
| 
								 | 
							
									"github.com/klauspost/compress/zstd"
							 | 
						||
| 
								 | 
							
									"io"
							 | 
						||
| 
								 | 
							
								)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								var sharedZSTDWriterPool *WriterPool
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func init() {
							 | 
						||
| 
								 | 
							
									var maxSize = utils.SystemMemoryGB() * 256
							 | 
						||
| 
								 | 
							
									if maxSize == 0 {
							 | 
						||
| 
								 | 
							
										maxSize = 256
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
									sharedZSTDWriterPool = NewWriterPool(maxSize, int(zstd.SpeedBestCompression), func(writer io.Writer, level int) (Writer, error) {
							 | 
						||
| 
								 | 
							
										return newZSTDWriter(writer, level)
							 | 
						||
| 
								 | 
							
									})
							 | 
						||
| 
								 | 
							
								}
							 |