Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the TinyMemoryMappedFile class.
        /// </summary>
        /// <param name="memoryMappedFile">An instance of a memory mapped file</param>
        /// <param name="fileWaitHandle">A manual reset EventWaitHandle that is to be used to signal file changes</param>
        /// <param name="maxFileSize">The maximum amount of data that can be written to the file memory mapped file</param>
        /// <param name="readWriteLock">A read/write lock that will be used to control access to the memory mapped file</param>
        /// <param name="disposeLock">Set to true if the read/write lock is to be disposed when this instance is disposed</param>
        public TinyMemoryMappedFile(MemoryMappedFile memoryMappedFile, EventWaitHandle fileWaitHandle, long maxFileSize, ITinyReadWriteLock readWriteLock, bool disposeLock)
        {
            this.readWriteLock    = readWriteLock ?? throw new ArgumentNullException(nameof(readWriteLock));
            this.memoryMappedFile = memoryMappedFile ?? throw new ArgumentNullException(nameof(memoryMappedFile));
            this.fileWaitHandle   = fileWaitHandle ?? throw new ArgumentNullException(nameof(fileWaitHandle));
            this.disposeLock      = disposeLock;

            MaxFileSize = maxFileSize;

            disposeWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);

            fileWatcherTask = Task.Run(() => FileWatcher());
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the TinyMemoryMappedFile class.
        /// </summary>
        /// <param name="memoryMappedFile">An instance of a memory mapped file</param>
        /// <param name="fileWaitHandle">A manual reset EventWaitHandle that is to be used to signal file changes</param>
        /// <param name="maxFileSize">The maximum amount of data that can be written to the file memory mapped file</param>
        /// <param name="readWriteLock">A read/write lock that will be used to control access to the memory mapped file</param>
        /// <param name="disposeLock">Set to true if the read/write lock is to be disposed when this instance is disposed</param>
        public TinyMemoryMappedFile(MemoryMappedFile memoryMappedFile, EventWaitHandle fileWaitHandle, Int64 maxFileSize, ITinyReadWriteLock readWriteLock, Boolean disposeLock)
        {
            _readWriteLock    = readWriteLock ?? throw new ArgumentNullException(nameof(readWriteLock));
            _memoryMappedFile = memoryMappedFile ?? throw new ArgumentNullException(nameof(memoryMappedFile));
            _fileWaitHandle   = fileWaitHandle ?? throw new ArgumentNullException(nameof(fileWaitHandle));
            _disposeLock      = disposeLock;

            MaxFileSize = maxFileSize;

            _disposeWaitHandle = new EventWaitHandle(false, EventResetMode.ManualReset);

            _fileWatcherTask = Task.Run(FileWatcher);
        }
Beispiel #3
0
        public TinyMemoryMappedFile(MemoryMappedFile memoryMappedFile, EventWaitHandle waitHandle, long maxFileSize, ITinyReadWriteLock readWriteLock, bool disposeLock)
        {
            if (maxFileSize <= 0)
            {
                throw new ArgumentException("Max file size can not be less than 1 byte", nameof(maxFileSize));
            }

            this.maxFileSize   = maxFileSize;
            this.readWriteLock = readWriteLock;
            this.disposeLock   = disposeLock;

            this.memoryMappedFile = memoryMappedFile;
            this.waitHandle       = waitHandle;
            fileWatcherTask       = Task.Factory.StartNew(FileWatcher);
        }
Beispiel #4
0
        public TinyMemoryMappedFile(string name, long maxFileSize, ITinyReadWriteLock readWriteLock, bool disposeLock)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentException("File must be named", nameof(name));
            }

            if (maxFileSize <= 0)
            {
                throw new ArgumentException("Max file size can not be less than 1 byte", nameof(maxFileSize));
            }

            this.maxFileSize   = maxFileSize;
            this.readWriteLock = readWriteLock;
            this.disposeLock   = disposeLock;

            memoryMappedFile = CreateOrOpenMemoryMappedFile(name, maxFileSize);
            waitHandle       = CreateEventWaitHandle(name);
            fileWatcherTask  = Task.Factory.StartNew(FileWatcher);
        }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the TinyMemoryMappedFile class.
 /// </summary>
 /// <param name="name">A system wide unique name, the name will have a prefix appended before use</param>
 /// <param name="maxFileSize">The maximum amount of data that can be written to the file memory mapped file</param>
 /// <param name="readWriteLock">A read/write lock that will be used to control access to the memory mapped file</param>
 /// <param name="disposeLock">Set to true if the read/write lock is to be disposed when this instance is disposed</param>
 public TinyMemoryMappedFile(string name, long maxFileSize, ITinyReadWriteLock readWriteLock, bool disposeLock)
     : this(CreateOrOpenMemoryMappedFile(name, maxFileSize), CreateEventWaitHandle(name), maxFileSize, readWriteLock, disposeLock)
 {
 }
Beispiel #6
0
 /// <summary>
 /// Initializes a new instance of the TinyMemoryMappedFile class.
 /// </summary>
 /// <param name="name">A system wide unique name, the name will have a prefix appended before use</param>
 /// <param name="maxFileSize">The maximum amount of data that can be written to the file memory mapped file</param>
 /// <param name="readWriteLock">A read/write lock that will be used to control access to the memory mapped file</param>
 /// <param name="disposeLock">Set to true if the read/write lock is to be disposed when this instance is disposed</param>
 public TinyMemoryMappedFile(String name, Int64 maxFileSize, ITinyReadWriteLock readWriteLock, Boolean disposeLock)
     : this(CreateOrOpenMemoryMappedFile(name, maxFileSize), CreateEventWaitHandle(name), maxFileSize, readWriteLock, disposeLock)
 {
 }