Ejemplo n.º 1
0
        /* build the decoded waveform table */
        void build_decoded_waveform(Pointer <uint8_t> rgnbase)  //uint8_t *rgnbase)
        {
            if (rgnbase != null)
            {
                m_wavedata = rgnbase;
            }
            else
            {
                m_waveram_alloc = new MemoryContainer <uint8_t>(0x400);  //m_waveram_alloc = make_unique_clear<uint8_t[]>(0x400);
                m_wavedata      = new Pointer <uint8_t>(m_waveram_alloc);
            }

            /* 20pacgal has waves in RAM but old sound system */
            int size;

            if (rgnbase == null && m_voices != 3)
            {
                m_wave_size = 1;
                size        = 32 * 16; /* 32 samples, 16 waveforms */
            }
            else
            {
                m_wave_size = 0;
                size        = 32 * 8; /* 32 samples, 8 waveforms */
            }

            for (int v = 0; v < MAX_VOLUME; v++)
            {
                m_waveform[v] = new MemoryContainer <int16_t>(size);  //m_waveform[v] = std::make_unique<int16_t[]>(size);
            }
            for (int offset = 0; offset < 256; offset++)
            {
                update_namco_waveform(offset, m_wavedata[offset]);
            }
        }
 public PermanentAllocator()
 {
     // Filling 18th container would mean having items in memory occupying over 4 GB RAM
     m_MemoryContainers    = new MemoryContainer[18];
     m_MemoryContainers[0] = m_CurrentContainer = new MemoryContainer(m_AllocationCapacity);
     m_ContainerCount      = 1;
 }
Ejemplo n.º 3
0
        public void Constructor_WithValidName_SetsName(string name)
        {
            // Arrange & Act
              var container = new MemoryContainer(name);

              // Assert
              Assert.That(container.Name, Is.EqualTo(name));
        }
 private void EnsureMemoryIsAvailable(int size)
 {
     if (!m_CurrentContainer.HasFreeSpace(size))
     {
         m_AllocationCapacity *= 2;
         m_MemoryContainers[m_ContainerCount++] = m_CurrentContainer = new MemoryContainer(m_AllocationCapacity);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Form方式上传文件提交之后根据时间戳获取文件
        /// </summary>
        /// <param name="timeStamp"></param>
        /// <returns></returns>
        public DocumentContract GetTemp(string timeStamp)
        {
            var document = MemoryContainer.Pop(timeStamp) as DocumentContract;

            if (document != null)
            {
                return(document);
            }
            throw new HttpResponseException(HttpStatusCode.NotFound);
        }
Ejemplo n.º 6
0
        public ActionResult Add()
        {
            _logger.Info("DocumentController 添加文档");

            try
            {
                var fileCollection = _requestProvider.FileCollection;

                var userId    = _contextService.UserId;
                var userName  = _contextService.NickName;
                var depId     = _contextService.DepId;
                var timeStamp = _requestProvider["TimeStamp"];
                var spaceId   = _requestProvider["SpaceId"];

                var space = string.IsNullOrWhiteSpace(spaceId) ? _spaceService.GetDefaultSpace() : _spaceService.GetSpace(spaceId);

                _logger.Info(string.Format("Add Document, spaceId:[{0}];spaceSeqNo:[{1}], spaceName:[{2}], userId:[{3}];userName:[{4}]。",
                                           space.Id, space.SpaceSeqNo, space.SpaceName, userId, userName));



                var documents = new List <DocumentObject>();

                for (int i = 0; i < fileCollection.Count; ++i)
                {
                    var document = DocumentBuilder.Build(fileCollection[i], space.Id.ToString(), space.SpaceSeqNo, space.SpaceName, userId, userName, depId, Visible.Public);
                    documents.Add(document);
                    var mimeType = MimeMapping.GetMimeMapping(document.FileName);
                    _storePolicy.AddStream(fileCollection[i].FileStream, mimeType, document.StorePath);
                }


                var contracts = _documentService.Add(documents);
                if (!string.IsNullOrWhiteSpace(timeStamp))
                {
                    MemoryContainer.Push(timeStamp, documents);
                }

                return(Json(new UploadViewModel(ErrorMessages.Success,
                                                ErrorMessages.GetErrorMessages(ErrorMessages.Success),
                                                contracts)));
            }
            catch (Exception ex)
            {
                _logger.Error(ex.StackTrace);
                _logger.Error(ex.Message);
            }

            _logger.Error(ErrorMessages.GetErrorMessages(ErrorMessages.UploadFailed));
            return(Json(new UploadViewModel(ErrorMessages.UploadFailed,
                                            ErrorMessages.GetErrorMessages(ErrorMessages.UploadFailed))));
        }
Ejemplo n.º 7
0
            protected MemoryContainer <MemoryContainer <FT> > m_A;  //plib::parray2D<FT, SIZE, m_pitch_ABS> m_A;


            protected matrix_solver_direct_t(devices.nld_solver main_solver, string name, matrix_solver_t_net_list_t nets, solver.solver_parameters_t params_, size_t size)
                : base(main_solver, name, nets, params_, size)
            {
                m_pitch = m_pitch_ABS != 0 ? m_pitch_ABS : (((size + 0) + 7) / 8) * 8;
                //, m_A(size, m_pitch)
                m_A = new MemoryContainer <MemoryContainer <FT> >((int)size);
                for (int i = 0; i < (int)size; i++)
                {
                    m_A[i] = new MemoryContainer <FT>((int)m_pitch);
                }


                this.build_mat_ptr(m_A);
            }
Ejemplo n.º 8
0
        public pmatrix_cr(size_t n)
        {
            diag    = new C [n];                                   //diag(n)
            row_idx = new C [n + 1];                               //row_idx(n+1)
            col_idx = new C [n * n];                               //col_idx(n*n)
            A       = new MemoryContainer <T>((int)(n * n), true); //A(n*n)
            nz_num  = 0;
            ////, nzbd(n * (n+1) / 2)
            m_nzbd = new pmatrix2d_vrl <C>(n, n);
            m_size = n;


            for (size_t i = 0; i < n + 1; i++)
            {
                row_idx[i] = c_ops.cast(0);
            }
        }
Ejemplo n.º 9
0
        //-------------------------------------------------
        //  dirty_list - atomically get the current dirty
        //  list for a client
        //-------------------------------------------------
        public MemoryContainer <uint32_t> dirty_list(out uint32_t mindirty, out uint32_t maxdirty)  //const uint32_t *dirty_list(uint32_t &mindirty, uint32_t &maxdirty)
        {
            // if nothing to report, report nothing and don't swap
            MemoryContainer <uint32_t> result = m_dirty[m_liveIdx].dirty_list(out mindirty, out maxdirty);

            if (result == null)
            {
                return(null);
            }

            // swap the live and previous lists
            int tempIdx = m_liveIdx;  // dirty_state *temp = m_live;

            m_liveIdx     = m_previousIdx;
            m_previousIdx = tempIdx;

            // reset new live one and return the pointer to the previous
            m_dirty[m_liveIdx].reset();  // m_live.reset();

            return(result);
        }
Ejemplo n.º 10
0
        public string name;                             // short name of the system


        public game_driver(device_type type, string parent, string year, string manufacturer, machine_creator_wrapper machine_creator, ioport_constructor ipt, driver_init_wrapper driver_init, MemoryContainer <tiny_rom_entry> rom, int monitor, u64 flags, string name, string fullname)
        {
            this.type            = type;
            this.parent          = parent;
            this.year            = year;
            this.manufacturer    = manufacturer;
            this.machine_creator = machine_creator;
            this.ipt             = ipt;
            this.driver_init     = driver_init;
            this.rom             = new Pointer <tiny_rom_entry>(rom);
            this.compatible_with = null;
            this.default_layout  = null;
            this.flags           = (machine_flags.type)((u64)(u32)monitor | flags | MACHINE_TYPE_ARCADE);
            this.name            = name;
        }
Ejemplo n.º 11
0
        public DocumentContract Add()
        {
            _logger.Info("DocumentController 添加文档.");

            var userId   = _requestProvider["UserId"];
            var spaceId  = _requestProvider["SpaceId"];
            var userName = _requestProvider["UserName"];
            var depId    = _requestProvider["DepId"];
            var visible  = _requestProvider["Visible"];
            var path     = _requestProvider["Path"];

            var timeStamp = _requestProvider["TimeStamp"];

            if (string.IsNullOrWhiteSpace(userId))
            {
                _logger.Error("文档参数错误, 缺少 UserId 参数.");
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
            _logger.InfoFormat("文档参数userId:{0}", userId);

            if (string.IsNullOrWhiteSpace(userName))
            {
                _logger.Error("文档参数错误, 缺少 userName 参数.");
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
            _logger.InfoFormat("文档参数userName:{0}", userName);

            if (string.IsNullOrWhiteSpace(depId))
            {
                _logger.Error("文档参数缺少 depId 参数,默认设置为空");
                depId = string.Empty;
            }
            _logger.InfoFormat("文档参数depId:{0}", depId);

            var visiblity = Visible.Public;

            if (!string.IsNullOrWhiteSpace(visible))
            {
                visiblity = (Visible)Enum.Parse(typeof(Visible), visible);
                _logger.InfoFormat("文档参数为:{0}", visiblity);
            }
            else
            {
                _logger.Info("文档参数缺少 visible 参数,默认设置为Public");
            }

            SpaceObject space;

            if (string.IsNullOrWhiteSpace(path))
            {
                _logger.Info("文档参数缺少 path 参数,采用spaceId参数");
                space = string.IsNullOrWhiteSpace(spaceId) ? _spaceService.GetDefaultSpace() : _spaceService.GetSpace(spaceId);
            }
            else
            {
                _logger.InfoFormat("文档参数path:{0}", path);
                space = _spaceService.MakeSpace(string.Empty, path, userId, userName, depId, visiblity);
            }

            var fileData = _requestProvider.FileCollection[0];

            if (fileData == null)
            {
                _logger.Error("文档参数错误, fileData ContentLength为0.");
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }

            _logger.Info(string.Format("Add Document, spaceId:[{0}];userId:[{1}];userName:[{2}]。", spaceId, userId, userName));

            try
            {
                var document = DocumentBuilder.Build(fileData,
                                                     space.Id.ToString(),
                                                     space.SpaceSeqNo,
                                                     space.SpaceName,
                                                     userId,
                                                     userName,
                                                     depId,
                                                     visiblity);
                var mimeType = MimeMapping.GetMimeMapping(document.FileName);
                _storePolicy.AddStream(fileData.FileStream, mimeType, document.StorePath);

                var documentObj = _documentService.Add(document);
                if (documentObj.DocumentCategory != DocumentCategory.Image)
                {
                    documentObj.DisplayPath = documentObj.PreviewUrl;
                }

                var contract = documentObj.ToObject <DocumentContract>();

                if (!string.IsNullOrWhiteSpace(timeStamp))
                {
                    MemoryContainer.Push(timeStamp, contract);
                }

                return(contract);
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
                _logger.Error(ex.StackTrace);
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }