public static void Main(string[] args) { RegionAllocator.Initialize(); for (int i = 0; i < 50; ++i) { var region = RegionAllocator.AllocateRegion(100000); using (RegionContext regContext = RegionContext.Create(region)) { // List<TestClass> objList = new List<TestClass>(); RegionLinkedList<TestClass> objList = new RegionLinkedList<TestClass>(); //Dictionary<int, TestClass> objDict = new Dictionary<int, TestClass>(); for (int j = 0; j < 2; ++j) { // objList.Add(new TestClass(region, 10)); objList.InsertFirst(new TestClass(10)); // objList.InsertFirst(region, new TestClass(region, 10)); // objDict.Add(j, new TestClass(10)); } } RegionAllocator.FreeRegion(region); if (i % 10 == 0) { GC.Collect(); } } }
public static void Main(string[] args) { if (args.Length != 2) { Console.WriteLine("Unexpected number of arguments. Please specify: num_contexts, num_repetitions"); return; } RegionAllocator.Initialize(); int num_contexts = Convert.ToInt32(args[0]); int num_repetitions = Convert.ToInt32(args[1]); Region region = RegionAllocator.AllocateRegion(4096); Int64 start; Int64 end; Int64 cycles = 0; for (int i = 0; i < num_repetitions; ++i) { start = RegionAllocator.NativeGetPerformanceCounter(); using (RegionContext regContext = RegionContext.Create(region)) { } end = RegionAllocator.NativeGetPerformanceCounter(); cycles += end - start; } Print(cycles / num_repetitions); }
public static void Main(string[] args) { RegionAllocator.Initialize(); if (args.Length != 1) { Console.WriteLine("Unexpected number of arguments. Please specify: num_regions"); return; } int num_regions = Convert.ToInt32(args[0]); Region[] regions = new Region[num_regions]; for (int i = 0; i < num_regions; ++i) { regions[i] = RegionAllocator.AllocateRegion(10000); } Region region = RegionAllocator.AllocateRegion(10000); using (RegionContext regContext = RegionContext.Create(region)) { for (int i = 0; i < num_regions; ++i) { RegionAllocator.FreeRegion(regions[i]); } } Region failedRegion = RegionAllocator.AllocateRegion(10000); Console.WriteLine("Finish"); }
public void onNotify(TTime time) { if (vals.ContainsKey(time)) { Region outputRegion = RegionAllocator.AllocateRegion(NaiadSimulator.OUTPUT_REGION_SIZE); var output = new Buffer <TTime, PairNonCloneable <TKey, RegionLinkedList <TInput> > >(outputRegion, time); int outputOffset = 0; using (RegionContext regContext = RegionContext.Create(outputRegion)) { foreach (var group in vals[time]) { // NOTE: In real Naiad we might have to copy the pair. output.set(outputOffset, new PairNonCloneable <TKey, RegionLinkedList <TInput> >(group.Key, group.Value)); outputOffset++; } } output.send(outputRegion); vals.Remove(time); Region dictRegion = dictRegions[time]; dictRegions.Remove(time); RegionAllocator.FreeRegion(dictRegion); } }
public void onReceive(Message <TTime, TInput> message) { Region outputRegion = RegionAllocator.AllocateRegion(NaiadSimulator.OUTPUT_REGION_SIZE); var output = new Buffer <TTime, TOutput>(outputRegion, message.time); int outputOffset = 0; TInput input; using (RegionContext regContext = RegionContext.Create(outputRegion)) { for (int i = 0; i < message.length; i++) { // Note: Automatically annotated code may require this Clone, but // in the manually written one we don't need it. // input = (TInput)message.payload[i].Clone(); input = message.payload[i]; foreach (var res in this.function(input)) { output.set(outputOffset, res); outputOffset++; } } } // The region will be freed. output.send(outputRegion); }
public TerminologyVocabularyView(TerminologyVocabularyViewModel viewModel) : this() { DataContext = viewModel; RegionContext.GetObservableContext(this).PropertyChanged += (s, e) => { }; }
public MappyController(ILogger <MappyController> logger, RegionContext cx, WebManifest manifest) { _logger = logger; _cxt = cx; _manifest = manifest; }
private static void OnRegionContextChanged(BindableObject bindable, object oldValue, object newValue) { if (oldValue != newValue && bindable is VisualElement view) { RegionContext.GetObservableContext(view).Value = newValue; } }
public void PlayDataFromMemory(AggregateVertex <AggDocument, int> aggVertex, string filename) { int time_epoch = 0; RegionLinkedList <Message <int, Pair <Integer, AggDocument> > > messages; using (StreamReader file = File.OpenText(filename)) { Region inputRegion = RegionAllocator.AllocateRegion(NaiadSimulator.TMP_REGION_SIZE); using (RegionContext regContext = RegionContext.Create(inputRegion)) { messages = new RegionLinkedList <Message <int, Pair <Integer, AggDocument> > >(); while (true) { var line = file.ReadLine(); if (line == null) { break; } var elements = line.Split(' '); if (elements[0] == "BEGIN") { int time = Convert.ToInt32(elements[1]); int batch_size = Convert.ToInt32(elements[2]); Message <int, Pair <Integer, AggDocument> > msg = new Message <int, Pair <Integer, AggDocument> >(time, batch_size); for (int i = 0; i < batch_size; i++) { elements = file.ReadLine().Split(' '); msg.put(new Pair <Integer, AggDocument>( new Integer(Convert.ToInt32(elements[3])), new AggDocument(new Integer(Convert.ToInt32(elements[1])), new Integer(Convert.ToInt32(elements[2])), new Integer(Convert.ToInt32(elements[3])), elements[4]))); } messages.InsertFirst(msg); time_epoch++; } } } } Int64 start = RegionAllocator.NativeGetPerformanceCounter(); for (Node <Message <int, Pair <Integer, AggDocument> > > cur = messages.Head; cur != default(Node <Message <int, Pair <Integer, AggDocument> > >); cur = cur.Next) { aggVertex.onReceive((Message <int, Pair <Integer, AggDocument> >)cur.Data.Clone()); aggVertex.onNotify(--time_epoch); } // NOTE: We do not free the input region because we don't want to include // it in measuring the runtime. The input region is just used as a // mechanism to load the data into memory. Int64 end = RegionAllocator.NativeGetPerformanceCounter(); Utils.Print(end - start); }
public PersonDetail() { InitializeComponent(); #region RegionContext-使用RegionContext将数据传递给嵌套区域 RegionContext.GetObservableContext(this).PropertyChanged += PersonDetail_PropertyChanged; #endregion }
public void onNotify(TTime time) { if (stateByTime.ContainsKey(time)) { Region outputRegion = RegionAllocator.AllocateRegion(NaiadSimulator.OUTPUT_REGION_SIZE); var output = new Buffer <TTime, Pair <Integer, TState> >(outputRegion, time); int outputOffset = 0; using (RegionContext regContext = RegionContext.Create(outputRegion)) { foreach (var pair in stateByTime[time]) { // Note: Automatically annotated code may require this Clone, but // in the manually written one we don't need it. // output.set(outputOffset, // new Pair<Integer, TState>((Integer)pair.Key.Clone(), // (TState)pair.Value.Clone())); output.set(outputOffset, new Pair <Integer, TState>(pair.Key, pair.Value)); outputOffset++; } } // The region will be freed. output.send(outputRegion); stateByTime.Remove(time); Region dictRegion = dictRegions[time]; dictRegions.Remove(time); RegionAllocator.FreeRegion(dictRegion); } }
public void Execute(string[] args) { Region actorRegion = RegionAllocator.AllocateRegion(NaiadSimulator.ACTOR_REGION_SIZE); RegionAggregateVertex <AggDocument, int> aggregateVertex; using (RegionContext regContext = RegionContext.Create(actorRegion)) { aggregateVertex = new RegionAggregateVertex <AggDocument, int>( (accDoc, newDoc) => new AggDocument(accDoc.docId, accDoc.length + newDoc.length, accDoc.authorId, accDoc.title)); // Note: Depending on how we use batching we may or may not have to // clone the fields. // (accDoc, newDoc) => new AggDocument(new Integer(accDoc.docId), // accDoc.length + newDoc.length, // new Integer(accDoc.authorId), // String.Copy(accDoc.title))); } PlayData(aggregateVertex, args[0], actorRegion); // PlayDataFromMemory(aggregateVertex, args[0], actorRegion); RegionAllocator.FreeRegion(actorRegion); }
public static void UseRegionContext <TViewModel, TRegionContext>(this UserControl userControl, Action <TViewModel, TRegionContext> initializeAction) { var regionContext = RegionContext.GetObservableContext(userControl); void UpdateRegionContext() { if (regionContext.Value == null) { return; } if (userControl.DataContext == null) { return; } var context = (TRegionContext)regionContext.Value; var viewModel = (TViewModel)userControl.DataContext; initializeAction(viewModel, context); } regionContext.PropertyChanged += (_, __) => UpdateRegionContext(); userControl.DataContextChanged += (_, __) => UpdateRegionContext(); }
public ModuleBWorkspace(IStringCopyService stringCopyService)/*IEventAggregator eventAggregator*/ { // código exclusivo para la recepción de un string a traves de un agregador de eventos. var eventAggregator = ServiceLocator.Current.GetInstance <IEventAggregator>(); // eventAggregator.GetEvent<MyCopyDataAddedEvent>().Subscribe(OnCopyDataReceived, ThreadOption.UIThread); var evento = eventAggregator.GetEvent <MyCopyDataAddedEvent>(); if (subscriptionToken != null) { evento.Unsubscribe(subscriptionToken); } subscriptionToken = evento.Subscribe(OnCopyDataReceived, ThreadOption.UIThread, true); InitializeComponent(); //código exclusivo para recepción de un string a traves de un servicio compartido stringCopyService.CopyStringEvent += TheStringCopyService_CopyStringEvent; //código exclusivo para la recepción de datos atraves del regioncontext. // get the region context from the current view // (which is plugged into the region) Microsoft.Practices.Prism.ObservableObject <object> regionContexto = RegionContext.GetObservableContext(this); // set an event handler to run when PropertyChanged event is fired regionContexto.PropertyChanged += regionContext_PropertyChanged; }
public void Execute(string[] args) { int windowSize = 4; Region actorRegion = RegionAllocator.AllocateRegion(NaiadSimulator.ACTOR_REGION_SIZE); RegionWindowJoinVertex <Document, Author, int, JoinOutput> windowJoinVertex; using (RegionContext regContext = RegionContext.Create(actorRegion)) { windowJoinVertex = new RegionWindowJoinVertex <Document, Author, int, JoinOutput>( windowSize, document => document.authorId, author => author.id, (document, author) => new JoinOutput(document.title, author.name, author.age)); // Note: Depending on how we use batching we may or may not have to // clone the fields. // (document, author) => new JoinOutput(String.Copy(document.title), // String.Copy(author.name), // author.age)); } PlayData(windowJoinVertex, args[0], args[1], actorRegion); RegionAllocator.FreeRegion(actorRegion); }
public SalesView(SalesVM salesVM) { InitializeComponent(); DataContext = salesVM; salesvm = salesVM; SalesPad.SalesVM = salesVM; SalesPad.SalesView = this; ((INotifyCollectionChanged)SalesLst.Items).CollectionChanged += SalesView_CollectionChanged; SalesLst.SelectionChanged += SalesLst_SelectionChanged; SalesLst.LayoutUpdated += SalesLst_LayoutUpdated; HideReceipt(); ShowTransaction(); SetUpSalesPad(); ObservableObject <object> viewRegionContext = RegionContext.GetObservableContext(this); viewRegionContext.PropertyChanged += this.ViewRegionContext_OnPropertyChangedEvent; }
public SingleConceptView(SingleConceptViewModel viewModel) : this() { DataContext = viewModel; RegionContext.GetObservableContext(this).PropertyChanged += (s, e) => { }; }
public IActionResult Create(RegionViewModels regionModel) { RegionContext regionContext = new RegionContext(connectionString); regionModel.Region = regions(); IActionResult retour = null; if (ModelState.IsValid) { Region region = new Region(); region.Identifiant = regionModel.Identifiant; region.Nom = regionModel.Nom; bool isOK = regionContext.Insert(region); retour = RedirectToAction("Index"); } else { retour = View(regionModel); } return(retour); }
public IActionResult Edit(RegionViewModels regionModel) { RegionContext regionContext = new RegionContext(connectionString); regionModel.Region = regions(); //Rajouter des contrôles dynamiques //if(bugModel.IdentifiantSeverite == 2) //{ // ModelState.AddModelError("IdentifiantSeverite", "Ne peut être égal à 2"); //} IActionResult retour = null; if (ModelState.IsValid) { Region region = new Region(); region.Identifiant = (int)regionModel.Identifiant; region.Nom = regionModel.Nom; bool isOK = regionContext.Update(region); retour = RedirectToAction("Index"); } else { retour = View(regionModel); } return(retour); }
public PolicySearchResultsView() { this.InitializeComponent(); RegionContext.GetObservableContext(this).PropertyChanged += (s, e) => this.ViewModel.PolicySearchResult = RegionContext.GetObservableContext(this).Value as PolicySearchResult; }
public StaffView(StaffViewModel viewModel) { InitializeComponent(); DataContext = viewModel; var regionContext = RegionContext.GetObservableContext(this); regionContext.PropertyChanged += RegionContextOnPropertyChanged; }
public UserDetailsView(UserDetailsViewModel viewModel) { InitializeComponent(); this.DataContext = viewModel; RegionContext.GetObservableContext(this).PropertyChanged += (s, e) => viewModel.CurrentUser = RegionContext.GetObservableContext(this).Value as User; }
public CreateBillingOfficeButtonView(CreateBillingOfficeButtonViewModel createBillingOfficeButtonViewModel) : this() { DataContext = createBillingOfficeButtonViewModel; var regionContext = RegionContext.GetObservableContext(this); regionContext.PropertyChanged += (s, e) => { createBillingOfficeButtonViewModel.AgencyKey = ( long )regionContext.Value; }; }
public PolicyDetailMenuView() { InitializeComponent(); RegionContext.GetObservableContext(this).PropertyChanged += (s, e) => ViewModel.MenuContext = (int)RegionContext.GetObservableContext(this).Value; }
void SendParamRegionContext_Click(object sender, System.Windows.RoutedEventArgs e) { // get the region context from the region defining control Microsoft.Practices.Prism.ObservableObject <object> regionContext = RegionContext.GetObservableContext(WorkspaceRegion); // set the region context's value to the string we want to copy regionContext.Value = ShellParameter1.Text; }
public EmployeeDetailsView(EmployeeDetailsViewModel employeeDetailsViewModel) { InitializeComponent(); DataContext = employeeDetailsViewModel; RegionContext.GetObservableContext(this).PropertyChanged += (sender, e) => employeeDetailsViewModel.CurrentEmployee = RegionContext.GetObservableContext(this).Value as Employee; }
public PersonDetailsView(IPersonDetailsViewViewModel viewModel) : base(viewModel) { InitializeComponent(); RegionContext.GetObservableContext(this).PropertyChanged += (s, e) => { var context = (ObservableObject <object>)s; var selectedPerson = (Person)context.Value; (ViewModel as IPersonDetailsViewViewModel).SelectedPerson = selectedPerson; }; }
private static void SetContextToViews(IEnumerable views, object context) { foreach (var view in views) { if (view is VisualElement visualElement) { ObservableObject <object> contextWrapper = RegionContext.GetObservableContext(visualElement); contextWrapper.Value = context; } } }
private void DetachNotifyChangeEvent(IEnumerable views) { foreach (var view in views) { if (view is VisualElement visualElement) { ObservableObject <object> viewRegionContext = RegionContext.GetObservableContext(visualElement); viewRegionContext.PropertyChanged -= ViewRegionContext_OnPropertyChangedEvent; } } }
public IActionResult Delete(int id) { RegionContext regionContext = new RegionContext(connectionString); bool isOK = regionContext.Delete(id); DeleteRegionViewModels model = new DeleteRegionViewModels(); model.IsDeleted = isOK; return(View(model)); }