Using the same object in two actors at the same time
Hello,
I'm in doubt. In my application, for example i have three Hardware classes - Database, DAQ1, DAQ2.
Database class has one main method (except initialization methods) - Log Measure.
DAQ1 class also has one method - Get Voltage, and DAQ2 class has one method - Get Current.
Then i define two HAL (Hardware Abstraction Layer) classes - Measurement1 and Measurement2.
Each of those classes have two main methods, respectively - Measure Voltage and Measure Curent. They also have some initilziation methods.
In code, i create three objects of Hardware classes - Database, DAQ1 and DAQ2 and initiaze it. For example in Database private cluster i have DB RefNum, in DAQ1&2 i have device addresses etc.
Next I initialzie Measurement1 with two hardware objects - Database and DAQ1, and in the same way - Measurement2 with Database, and DAQ2 objects.
What Measure Voltage and Measure Curent (methods of Measurement1 and Measurement1 objects) do?
Measure Voltage method call DAQ1::Get Voltage method, then Database::Log Measure.
Similarly, Measure Current method call DAQ2::Get Voltage method, then Database::Log Measure.
Till now it's clear i think. It should work properly.
But now i incorporate Actor Framework, and define Measurement1 and Measurement2 as an actors.
Now i can run Measurement1 and Measurement2 at the same time, simultaneously, but this two actors share one object - Database. So my question - what is when actors want to use Database::Log measure method at the same time and this method is time cosuming (for example large pack of data).
Is one actor waits for second to stop executing this method of one shared object? I think yes because reentrancy setting (http://zone.ni.com/reference/en-XX/help/371361J-01/lvconcepts/reentrancy/)
But what, for example if i share one Hardware object of device (ADC converter) beetwen two HAL classes (Measurement1 and Measurement2). This Hardware object has two methods, for ex. Get Voltage At channel 1, and Get Voltage At Channel 2. Both of this methods cannot by call at the same time, because in physical device i can measure only at one channel in the same time.
Let the Get Voltage At channel X meausere take 10 seconds. Now i have huge chance, that Measurement 1 actor call Get Voltage At channel 1 method, and Measurement 2 wants to call Get Voltage At channel 2, when Get Voltage At channel 1 is in process. How to inform actor to wait till second actor release device resources?
Regards,
Kacper
Dear Kacper,
the way I understood, there are two separate questions in this post, namely:
I'm using a shared resource in multiple actors, and the code accessing the resource can take quite some time to execute. How can can I ensure this does not mess up the timing of one or all accessors?
I'm using a shared resource in multiple actors, and the code accessing the resource can generate errors if I try to access it from multiple places. How can I ensure synchronization between all accessors?
As for the first question, the optimal solution to separate the resource prone to timing issues in a different thread/actor. Put anything that is not strictly timed (file access, network comunication) in a separate loop. For each actor, you will get queue references to communicate with, so instead of logging the measurements in the actors where they are made, just queue them up for a different loop to process.
For the second part, the same logic still applies. Ideally, every singular resource should be handled by its own thread and nowhere else, so if anything else needs data from/to said resource, it can send a request to the dedicated thread or actor.
If, for some reason, this is not sufficient, you have to handle synchronization in some other way. There are a lot of techniques here, for example:
Create a named semaphore or lock as a part of the class. Have class functions use the semaphore before accessing the resource.
Use actor messages. Have a "resource in use" or "resource released" messages sent to all users whenever obtaining or releasing said resource.
Have a separate actor handle all resources, awarding them to threads needing them. This method also allows setting priorities between requests.
These are just a few examples, there are many other options.
Please let me know if this was helpful.
Kind regards:
Andrew Valko
National Instruments Hungary
Similar Messages
-
Hi
I am trying to copy one object from one lside to another slide in the same presentation. The only thing I get when pasting is a hyperink. Does anyone know how I can turn this off so that the image or the object is pasted as copied to the new slide?
Thanks a lotthere are some unexpected issues when copy and pasting.
As a workaround, use duplicate slide to get the same object in another slide, (select the slide in navigator and command D or right click > duplicate) -
Hi all,
I need to create service to access all unread mails of other mailbox's every time in Exchange server 2013, for that i trying to use Delegate access.
but i am not succeed. I am getting Error Every time : [The specified object was not found in the store]
error shows in FolderId in
var folderId = new FolderId(WellKnownFolderName.Inbox, userMailbox);
List<DelegateUser> newDelegates = new List<DelegateUser>();
DelegateUser emailDelegate = new DelegateUser("[email protected]");
emailDelegate.Permissions.InboxFolderPermissionLevel = DelegateFolderPermissionLevel.Editor;
newDelegates.Add(emailDelegate);
Mailbox mailbox = new Mailbox("[email protected]");
Collection<DelegateUserResponse> response = service.AddDelegates(mailbox, MeetingRequestsDeliveryScope.DelegatesAndSendInformationToMe, newDelegates); var userMailbox = new Mailbox(useremail);
var folderId = new FolderId(WellKnownFolderName.Inbox, userMailbox);
var itemView = new ItemView(20);
var userItems = service.FindItems(folderId, itemView);
i changed my code in many ways by adding new Delegate User with different folder permissions.
but i am getting same Error, Please help me.That error means you don't have rights to the Mailbox your trying to access. In Exchange by default the only user that has access to mailbox is the owner of the Mailbox, Exchange Administration rights does not grant you access to another users mailbox. You
need to either specifically grant rights to each mailbox using Add-MailboxPermissions or use EWS impersonation where you can impersonate the owner of the Mailbox see
http://msdn.microsoft.com/en-us/library/bb204095(EXCHG.140).aspx and
http://msdn.microsoft.com/en-us/library/office/dd633680(v=exchg.80).aspx
Cheers
Glen -
Getting the JAXB exception like "Two classes have the same XML type name-"
Getting the JAXB exception like "Two classes have the same XML type name...",
Here is the exception details:
Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Two classes have the same XML type name "city". Use @XmlType.name and @XmlType.namespace to assign different names to them. this problem is related to the following location: at com.model.City at public com.model.City com.model.Address.getCurrentCity() at com.model.Address this problem is related to the following location: at com.common.City at public com.common.City com.model.Address.getPreviousCity() at com.model.Address
at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at javax.xml.bind.ContextFinder.newInstance(Unknown Source) at javax.xml.bind.ContextFinder.find(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at com.PojoToXSD.main(PojoToXSD.java:17)
I took the example like:
package com.model; ---->this package contains 'Address' class and 'City' class
public class Address {
private String areaName; private City currentCity; private com.common.City previousCity;
package com.model;
public class City {
private String cityName;
Another city class in "com.common" package.
package com.common;
public class City {
private String pinCode;
We need to create XSDs and needs to do the Marshalling and unmarshalling with the existing code in our project(like as above example code), code does not have any annotations like "@XmlRootElement/@XmlType" and we can not able to change the source code.
I would like to know is there any solution to fix the above issue or any other ways to create XSDs and marshaling/unmarshalling(like MOXy..etc)?
It would be great if i can get the solution from any one....May thanks in advance.
Thanks,
Satya.Getting the JAXB exception like "Two classes have the same XML type name...",
Here is the exception details:
Exception in thread "main" com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions Two classes have the same XML type name "city". Use @XmlType.name and @XmlType.namespace to assign different names to them. this problem is related to the following location: at com.model.City at public com.model.City com.model.Address.getCurrentCity() at com.model.Address this problem is related to the following location: at com.common.City at public com.common.City com.model.Address.getPreviousCity() at com.model.Address
at com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at com.sun.xml.internal.bind.v2.ContextFactory.createContext(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at javax.xml.bind.ContextFinder.newInstance(Unknown Source) at javax.xml.bind.ContextFinder.find(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at javax.xml.bind.JAXBContext.newInstance(Unknown Source) at com.PojoToXSD.main(PojoToXSD.java:17)
I took the example like:
package com.model; ---->this package contains 'Address' class and 'City' class
public class Address {
private String areaName; private City currentCity; private com.common.City previousCity;
package com.model;
public class City {
private String cityName;
Another city class in "com.common" package.
package com.common;
public class City {
private String pinCode;
We need to create XSDs and needs to do the Marshalling and unmarshalling with the existing code in our project(like as above example code), code does not have any annotations like "@XmlRootElement/@XmlType" and we can not able to change the source code.
I would like to know is there any solution to fix the above issue or any other ways to create XSDs and marshaling/unmarshalling(like MOXy..etc)?
It would be great if i can get the solution from any one....May thanks in advance.
Thanks,
Satya. -
After REFRESH the cached object is not consistent with the database table
After REFRESH, the cached object is not consistent with the database table. Why?
I created a JDBC connection with the Oracle database (HR schema) using JDeveloper(10.1.3) and then I created an offline database (HR schema)
in JDeveloper from the existing database tables (HR schema). Then I made some updates to the JOBS database table using SQL*Plus.
Then I returned to the JDeveloper tool and refreshed the HR connection. But I found no any changes made to the offline database table JOBS in
JDeveloper.
How to make the JDeveloper's offline tables to be synchronized with the underling database tables?qkc,
Once you create an offline table, it's just a copy of a table definition as of the point in time you brought it in from the database. Refreshing the connection, as you describe it, just refreshes the database browser, and not any offline objects. If you want to syncrhnonize the offline table, right-click the offline table and choose "Generate or Reconcile Objects" to reconcile the object to the database. I just tried this in 10.1.3.3 (not the latest 10.1.3, I know), and it works properly.
John -
Are you aware of a possible bug in version 3.6.23? In the browser, for example, "two/" appears with the slash through the "o". Is this a known bug?
When the same text is view in another browsers it appears correctly as "two/".
I've checked, and the same problem appears in Firefox on another computer.
The two answers received so far have not provided an answer: is this a known bug in Firefox?
Thank you.You are on a Mac and that is a [http://en.wikipedia.org/wiki/Kerning kerning] problem. Don't you see the same problem in other applications if you choose the same font, font-weight and font-size.
I only find one other kerning [https://support.mozilla.com/questions/789254 question] here -- it is marked unsolved. I find it strange that Firefox got involved with this at all rather than leaving such things to the operating system and font metrics.
Does the problem go away with "command+0" (zero) which resets [http://kb.mozillazine.org/Zoom_text_of_web_pages zoom level] to normal. If you mess with the font sizes in your preferences because you want larger print that would have the same effect.
Also found this one recently reported for [https://support.mozilla.com/questions/892222 Firefox 7 in ubuntu 11.04] which appears much worse. If it involves Firefox and specific operating systems it becomes a lot harder to diagnose who or what is responsible. -
Recently, I make a program, now I face a big program:
I make the program by visual basic and photoshop script , but my client have different release of Photoshop, for example : photoshop 7.0 cs and cs2. I know every release of PhotoShop have ist own Object library, but in visual basic 6.0, I can only refer to one PhotoShop Object library. for example: if I refer to Photoshop 8.0 Object library, if my clients release of Photoshop is 7.0. there will be a error message : Run-time error '429 ( cant create object) Run-time error '430(Class does not support Automation or does not support expected interface), How can I refer to the PhotoShop Object library dynamically depend on the release of PhotoShop?
my email is : [email protected] .
any suggestion?Please read, and reply back here with information https://forums.adobe.com/thread/1499014
-and try some steps such as changing browsers and turning off your firewall for downloads -
Using a Dell 2407WFP with two Macs at the same time?
Hi ... I have a Dell Ultrasharp 24" WFP display that I was using with my old G4. Connectivity isn't the issue ... it works beautifully on both the G4 and my new Mini. I've read that I can put the VGA cable on the G4 (no biggie -- it's what I was using before) and I have the DVI on the Mini.
What I want to know is: Can I (and is it wise to) have both machines running at the same time and toggle the display between the two or should I keep one machine off when the other is on? There is a button on the display for toggling between a variety of displays.
I've activated file sharing, etc. on the old box, but there are some things I still can't do unless I'm on the G4 desktop -- mostly my graphic apps. I've been holding off from swapping cables around, but now it's getting to the point that I need to get back on the G4 because of apps that I don't have on the Mini.
I haven't put the VGA cable back on the G4 yet. It seems like it -should- work -- I just need some verification that it will or won't futz up something. I think what I might be most concerned about is that the monitor isn't powerful enough to run both machines at the same time, but I could be wrong.
The info at the Dell site is somewhat dated.
TIA!I use a KVM switch with a Dell monitor that has DVI and VGA inputs. I only route the K an M portions (keyboard and mouse) through the switch. The computers connect directly via VGA and DVI to the Monitor, and then I use the monitor's switch to make the video switch. Works fine. Don't worry about taxing the monitor.
I'd suggest buying the KVM switch from a vendor with easy return policies, since it can take a few tries to find a model you like. -
We are working on a film project on Adobe Premiere Pro CC 2014. Two editors are working on the same film project (same pproj file ) on two machines. As a result the bin structure and the file structure is exactly the same. We even bought two licenses for the respective machines to make matters simple (at least we thought it would).
Now when we share a sequence between the two machines, every time we have to import and re-link media. Also each sequence import comes with its own set of files, which are actually already present in the project. Basically the new sequences are looking to re-link the media to the original/ source files only and are completely ignoring the file structure present in the project.
In all editing softwares, timeline/ sequence sharing is a very common practise when working on multiple machines. Why is it so tedious in CC 2014? Every time we share a sequence between the two machines the media gets doubled and tripled in the project. As a result the project file size is increasing perpetually. Already Premiere CC 2014 is extremely laggy and slow, and this stupid bug is making it more difficult for us to finish our work on time.
Has anybody ever faced this issue? How do we solve it? We are willing to try out any workflow that you can suggest.Concurrently working on the same project it requires a specific implementation in all editing programs like Avid's Unity/ ISIS shared storage. That's what you are simply not considering. none of your issues would be any problem if your projects resided on a commonly accessed server or something like that. Check respective hardware solutions.
Mylenium -
Why does itunes separate the songs in the same album into two albums with the exact same info?
i have this album in my itunes thats shown as two, they both have the exact same info, artwork, and the files are even in the same album folder, but they just appear as two albulms. the first one has only track8 and the second one has all the other tracks? how can i fix this plz?
Sometimes iTunes does that. What I find often works is to add an "x" onto the end of all the artist and album names for the problem album, save it, then remove it again. If that doesn't work, try setting an album artist. I have also toggled problem albums as compilations even though they aren't, but some don't like using compilation.
-
Can the Sound Object control two sounds at once?
I have a sound object that I want to control two seperate
sounds in different movie clips..one is intro music which lives on
the main shell of the website along with the sound object. This
fades out into a loop that lives on another movie clip that loads
into the shell on a loadMovie action naturally.
My goal:
To control both sound clips with ONE sound object living in
the main flash site's shell. Can this be done or would I have to
have two seperate sound objects for each sound clip?
Thank you,
DaytonYou could write a fairly simple class that would act as a
wrapper for the sound class. In this class you would let it define
the 2 sound objects but then you would only need to use call to the
class object to control both. This could also be expanded to
control more than 2 sounds. It is not exactly what you were hoping
for but in the long term it would simplify sound control and be
reusable in pretty much any setting that required sound.
Tim -
Why is the FORM OBJECT selection not found in the Preferences/Accessibility selection?
Hello,
I am using the Dreamweaver cs6. I was wondering why the FORM OBJECT selection is not found in the Preferences/Accessibility selection?The engineers removed it. Why? That's anybody's guess. You'll have to add them manually. Please refer to the HTML5 forms workflow video below:
http://tv.adobe.com/watch/learn-dreamweaver-cc/html5-forms-workflow/
Nancy O. -
Can I use one GBIP-Interface with two programs at the same time?
Hi, I have one PCI-GBIP-controller with multiple instruments installed. Now I want to use these instruments with two differents programs at the same time.
E.g.: program 1 uses GPIB0::1 and GPIB0::3
and program 2 uses GPIB0::4 and GPIB0::7
Is this possible??
When I have tried to do this, I always got timeout errors..
Thanx in advance.
PhilippHi,
You shouldn't have any problems accessing different devices from different programs using the same interface. I even used the two VIs to communicate with the same device. Although not the best approach, VISA didn't return any errors.
DiegoF. -
How do I use the same profile for two users on the same computer
I use my laptop both at home and at work. And in each venue I use a different user log on. But I wish to have firefox use the same profile for each user log on. How can I get firefox to point to the same profile for each user?
Note that only one user (Firefox instance) can use a profile folder at the time, so if you would switch the Windows user to another account then you would first have to close Firefox.
* http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows
* http://kb.mozillazine.org/Shortcut_to_a_specific_profile
* http://kb.mozillazine.org/Using_multiple_profiles_-_Firefox
* http://kb.mozillazine.org/Bypassing_the_Profile_Manager -
Changing the same column in two tables at the same time
Hi,
Oracle 10g2
I have 2 tables:
1. tab1 : Stores people info
2. tab2 : Stores people insurance info
Both have an address field.
What I need to do is when tab1.address is updated I want the tab2.address to update automatically and
when tab2.address is updated I want tab1.address to update.
Is there a way to do this using triggers without having these triggers mutate?
Thanks,
Oleg
Edited by: user635344 on Oct 8, 2009 11:04 AMHi, Oleg,
Centinul, Toon, Hoek and Peter are right. (It would be unusual if any one of them were wrong.)
The addresses really ought to be in one table.
If you really must have them in two (or more) tables, then don't INSERT or UPDATE addresses direectly into the tables; use a separate stored procedure, not a trigger.
If you really must use a trigger (and this means a trigger on each table), then before each trigger updates the other table, check a flag to see if the current table is being updated because of DML on the other, and, if so, do nothing. If the current table is not being updated because of DML on the other, then set the flag before doing the update.
In the example below, I used a package variable as the flag. You could also use a SYS_CONTEXT or a Global Temporary Table.
CREATE TABLE tab1
( id NUMBER
, addr VARCHAR2 (25)
DROP TABLE tab2;
CREATE TABLE tab2
( id NUMBER
, addr VARCHAR2 (25)
CREATE OR REPLACE PACKAGE pk_x
AS
-- This package contains no functions or procedures, only 1 variable:
table_of_origin varchar2 (30);
END pk_x;
CREATE OR REPLACE TRIGGER tab1_aiu
AFTER INSERT OR UPDATE OF addr on tab1
FOR EACH ROW
BEGIN
IF pk_x.table_of_origin IS NULL
THEN
pk_x.table_of_origin := 'TAB1';
UPDATE tab2
SET addr = :NEW.addr
WHERE id = :NEW.id;
pk_x.table_of_origin := NULL;
END IF;
END tab1_aiu;
CREATE OR REPLACE TRIGGER tab2_aiu
AFTER INSERT OR UPDATE OF addr on tab2
FOR EACH ROW
BEGIN
IF pk_x.table_of_origin IS NULL
THEN
pk_x.table_of_origin := 'TAB2';
UPDATE tab1
SET addr = :NEW.addr
WHERE id = :NEW.id;
pk_x.table_of_origin := NULL;
END IF;
END tab1_aiu;
/I made this example as simple as possible. Production code would be a lot more complicated (e.g., checking to see if id was changed).
I tested this using the DML statements below.
The contents of both tables is shown after each statement.
INSERT INTO tab1 (id, addr) VALUES (1, '1 First St.');
ID_1 ADDR_1 ID_2 ADDR_2
1 1 First St.
INSERT INTO tab2 (id, addr) VALUES (1, 'Forstagatan 1');
ID_1 ADDR_1 ID_2 ADDR_2
1 Forstagatan 1 1 Forstagatan 1
UPDATE tab1
SET addr = 'Primo Place'
WHERE id = 1;
ID_1 ADDR_1 ID_2 ADDR_2
1 Primo Place 1 Primo PlaceThe query that displayed the contents is:
SELECT tab1.id AS id_1
, tab1.addr AS addr_1
, tab2.id AS id_2
, tab2.addr AS addr_2
FROM tab1
FULL OUTER JOIN tab2 ON tab1.id = tab2.id
ORDER BY NVL (tab1.id, tab2.id);
Maybe you are looking for
-
When I open mi iTunes, the error code -42032 pop out. I use iTunes since a few years and that's a new problem. I have download every new versions. I have desinstall and intall a new version with no succes. I don't know what is mean? Otherwise, all mi
-
My pc thinks my iphone is a camera
everytime i plug in my iphone is says camera connected and wants to know what program i want to use, how to i correct this?
-
There's a random extra line text on the login screen?!
I would love if someone could help me figure this one out... (Just installed 10.7) From my first Lion log in after the update: Just above the Sleep, Restart, and Shut Down buttons on the Lion Login Screen is an extra line of text. It's definitely the
-
How can I get back an upgrade I paid for?
I purchased an upgrade to reader where I can convert pdf files into Word, etc. and after my computer was refreshed I cant find it. how do I get it back? my email is [email protected]
-
T410s: Wifi dead, Bluetooth turned on, short?
I've had my T410s since 2010 built to spec, and apart from the screen corruption issue that has plagued these laptops, ultrabay battery falling out from chassis flex, and other growing pains from taking over the reins from IBM, it's been a relatively