Using boost::thread with Sun Studio C++ gives error

Hi,
I'm trying to compile a code which uses the boost thread library, but I get the following error:
CC -library=stlport4 -features=tmplife -features=tmplrefstatic -mt -c -o t t.cpp
"/opt/boost/include/boost/thread/pthread/mutex.hpp", line 142: Error: The function "pthread_mutex_timedlock" must have a prototype.
"/opt/boost/include/boost/thread/pthread/mutex.hpp", line 142: Error: The function "pthread_mutex_timedlock" must have a prototype.
"/opt/boost/include/boost/thread/detail/thread.hpp", line 344: Error: boost::thread::thread(boost::thread&) is not accessible from boost::move(boost::detail::thread_move_t<boost::thread>).
"/opt/boost/include/boost/thread/pthread/recursive_mutex.hpp", line 179: Error: The function "pthread_mutex_timedlock" must have a prototype.
"/opt/boost/include/boost/thread/pthread/recursive_mutex.hpp", line 179: Error: The function "pthread_mutex_timedlock" must have a prototype.
5 Error(s) detected.
make: *** [t] Error 5the sample source code in question here just a single include:
#include <boost/thread.hpp>This is with boost 1.40.0. I wonder what I'm doing wrong..
Akos

OK, I tried latest version of CC from Sun Studio 12 update 1 and can say that
- the error about constructor not being accessible is Sun C++ compiler "feature" (only called feature because it existed for so long) that allows binding of rvalues to non-const references; this "feature" will probably be turned off in the next release. It can't be changed in a patch because client's code might rely on it.
- the other errors are also not Boost-specific: the result of incompatibility of Linux headers and Sun C++ compiler; more thorough investigation is due, but in the past we had several problems like this. This particular can be solved by adding
-D_GNU_SOURCE to compile line.

Similar Messages

  • Problems with sun studio 12 in suse linux 11

    Hi.
    I installed Sun Studio 12 suse linux with no problems. However, the debugging modules (DBX) are not working any more. When I started Sun Studio, it gave a message about modules that could not be loaded in tha moment. I did not pay attention. But I noticed that all debugging options were disabled.
    Using the module manager, I saw the DBX module was not checked, and I could not change it. I was marked with a red X. So I thought to reinstall the application. However, the uninstall utility doesn't work either.
    According with the documentation, running ./uninstaller does it, but I get the following error message instead
    Exception in thread "main" java.lang.NoClassDefFoundError: uninstall_Sun_Studio_12/class
    Caused by: java.lang.ClassNotFoundException: uninstall_Sun_Studio_12.class
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    I tried to uninstall manually, and then execute installer, by using first the software manager in linux and deleting the producregistry file manually. It worked because I executed the installer. However, in Sun Studio IDE, debugging options are still not available despite I "reinstalled" the application. I checked the log files and they say the file uninstall_Sun_Studio_12.class could not be written.
    So my questions are:
    1. Is there any other way to repair Sun Studio? What could be the possible for this module to stop working?
    2. Does anyone have an idea of why the installer cannot write the uninstaller class?
    I found that perhaps problems regarding Java / Netbeans versions could be the problem, but the ones I have installed are those packages that were installed along with Sun Studio, and both are valid.
    Thank you very much.

    Perhaps you can simply delete the Sun Studio 12 installation tree, because it will not work on SUSE Linux 11.
    This OS is not supported, so any problems you see with SS12 on SUSE 11 will not be fixed.
    But we have a newer version, that should work better.
    You can try to download and install Sun Studio Express 2008/11 (extract pre-installed image from tar.bz2 file).
    Here is a pointer to the web page:
    http://developers.sun.com/sunstudio/downloads/express
    All you need is to provide a email address, and press "Download Now" button.
    You will see a page, that gives you 2 options to download Sun Studio Express 2008/11.
    Use "Option 2": Download Tarfile Installer
    Thanks,
    Nik

  • Is it possible to integrate j2ee enviroment with sun studio developer???

    Dear all,
    I currently developing a jsp based web application with sun studio enterprise but sun studio by default does not support j2ee environment, i think it only support to j2SE.
    i want to use persistence and enterprise beans with my application but don't know, how to do it with sun studio developer.
    i can install the persistence and ejb api's separately, but i dont know whether sun developer will support them
    Can any on tell, what is the best tool for web application developement, while i will need to java uml diagrams later on.
    i would be grateful, if someone can help, i am really desprate
    shafqat zaman

    Sun Java Studio Enterprise 8.1 (built on top on NetBeans 5.0) does support j2ee (and j2se) development.
    For developing j2ee applications, both NetBeans (latest version is 5.5, http://www.netbeans.org) and SJSE can be used. For a comparison on SJSE and NetBeans, please take a look at:
    http://forum.java.sun.com/thread.jspa?forumID=747&threadID=5113472
    For a list of all development tools from Sun, please take a look at http://developers.sun.com/prodtech/devtools/free/index.html..
    i want to use persistence and enterprise beans with my application but don't know,
    how to do it with sun studio developer.For j2ee development, please check out NetBeans 5.5 ; there are several tutorials available at http://www.netbeans.org/kb/index.html. (Since SJSE is built on top on NetBeans, SJSE can also be used and all the NetBeans documents also will apply to SJSE).

  • Compiling MySQL 5.1.26-rc with Sun Studio Express on Linux?

    I managed to compile MySQL 5.1.26-rc with Sun Studio Express on Linux (OpenSuse 10.2 on x64), but I get unexpected crashes every time a connection thread exits:
    (gdb) where
    #0  0x00002b2ce0649535 in raise () from /lib64/libc.so.6
    #1  0x00002b2ce064a990 in abort () from /lib64/libc.so.6
    #2  0x00002b2cdf949795 in __pthread_unwind () from /lib64/libpthread.so.0
    #3  0x00002b2cdf944425 in pthread_exit () from /lib64/libpthread.so.0
    #4  0x00000000005048b2 in one_thread_per_connection_end (thd=0x16d88f0, put_in_cache=false)
    at /home/mysql/debug/sql//mysqld.cc:1893
    #5  0x0000000000513b75 in handle_one_connection (arg=0x16d88f0) at /home/mysql/mysql-5.1.26-rc/sql//sql_connect.cc:1122
    #6  0x00002b2cdf94309e in start_thread () from /lib64/libpthread.so.0
    #7  0x00002b2ce06da4cd in clone () from /lib64/libc.so.6
    #8  0x0000000000000000 in ?? ()If I compile with gcc using e.g. BUILD/compile-amd64-debug-max, I have no issue! But I want to use Sun Studio in order to be consistent with the Solaris version, and also because Sun Studio is likely to produce better code.
    Here is the compilation script, it downloads and extracts the source tree and builds it (it assumes Sun Studio Express is installed in /opt/sun):
    #!/bin/bash
    export PATH=/opt/sun/sunstudioceres/bin:$PATH
    wget -q http://mir2.ovh.net/ftp.mysql.com/Downloads/MySQL-5.1/mysql-5.1.26-rc.tar.gz
    tar xpf mysql-5.1.26-rc.tar.gz
    cd mysql-5.1.26-rc
    # Explicitly specify libs to avoid linking with the STL.
    export LIBS="-xnolib -lCrun -lm -lc -lrt"
    autoreconf --force --install > autoreconf.log 2>&1
    export MY_FLAGS="-g -mt -xtarget=generic -m64"
    CC=cc CXX=CC CFLAGS=$MY_FLAGS CXXFLAGS=$MY_FLAGS ./configure --with-big-tables --without-embedded-server --disable-shared --with-pthread --with-ssl -with-plugins=max > configure.log 2>&1
    gmake -j > build.log 2>&1Any idea about what is going wrong?
    Thanks.

    Possibly the actual CC (or cc) command lines are not correct. The proper way to say not to link libCstd is the command-line option -library=no%Cstd. Then you don't need to add the default system libraries like -lc to the command line.
    Can you show the actual CC command lines that are generated by the makefile? They should be in the compilation log. I'd also like to see the command line(s) used to create dynamic libraries, if any, and the final executable.

  • Is it possible to run sun studio 12 ide with sun studio 8 compiler?

    Hi, i am in the process of evaluating sun studio 12. Our company cannot move to sun studio 12 compiler collection right now as it is a huge code base and it will take us few months even before we start using sun studio 12 compiler in our development environment. Is it possible to use sun studio 12 ide with sun studio 8 compiler collection(CC, dbx etc)? Your feedback is appreciated. thank you.

    There are two parts to the answer.
    1) whether you can
    To choose a compiler set follow Tools->Options->C/C++
    and in the BuildTools tab you'll see how it picks up
    compilers from your PATH.
    This dialog doesn't govern choice of dbx, which will always
    come from the installation. However you can alter which dbx
    is used by presetting the environment variable SPRO_DBX_PATH
    to teh full pathname of a dbx of your choice.
    2) whether you should
    The IDE should work reasonably well with older compilers. They
    are not that tightly bound.
    The IDE will not work well enough with an older dbx, especially as
    old as studio 8. However, while not officially supported or tested
    the SS12 dbx should be reasonably bwd compatible with code
    generated from older compilers.
    So my recommendation is: don't use SPRO_DBX_PATH and
    give the old compilers a try.

  • Trouble viewing disassembly with Sun Studio 11

    I was wondering how someone can bring up a window with a program�s disassembly when debugging a C program with Sun Studio 11. (SPARC). I would like to be able to set breakpoints at specific assembly instructions using Sun Studios�s GUI interface rather than using typed commands with DBX. I would also like to know how to get a window that shows the current value of the registers. Any help would be greatly appreciated.
    Chris

    Oops, it appears that you can't set breakpoints
    through Disassembler window, it just shows the code
    and current position within the code, that's all.It
    gives you better view of context than dbx's 'dis' or
    'list -i' commands, though.Actually you can set breakpoints through Disassembler window:
    - select an address, click right mouse button to open context menu
    - choose "Set Breakpoint"
    If you need this feature, please file an RFE (Request
    For Enhancement) through bugs.sun.comThe Disassembler window has been significantly improved between
    EA1 and FCS. Now users can set and delete breakpoints using the
    same way as they do in source file - click on the left gray area (toggle
    breakpoints). Also Disassembler window has "Step Into", "Step Over",
    "Step Out" and "Run To Cursor" buttons.
    Thanks,
    Nik

  • Can I use boost mobile with my unlocked iPhone 5

    Can I use boost mobile with my unlocked iPhone 5

    No.  Boost is a CDMA carrier, using the Sprint network and is not compatable with unlocked iPhone 5.
    Message was edited by: modular747

  • Core dump using iostream with Sun Studio 8

    I'm running on Solaris 9 using C++ compiler Sun Studio 8, and encoutered a very strange problem.
    My application failed with a core and here is the stack.
    [1] t_splay(0x3774b470, 0x387a0ec0, 0x389aec60, 0x39e5ef1f, 0x3774b470, 0x1), at 0xfc347930
    [2] t_delete(0x387a0ec0, 0x80, 0x39be9748, 0x20, 0x383ccd20, 0x0), at 0xfc347698
    [3] mallocunlocked(0x80, 0x0, 0x21b08, 0xfc3bc000, 0x10, 0x20), at 0xfc346d40
    [4] malloc(0x80, 0xfbaa7400, 0x1, 0x759c40, 0x0, 0x0), at 0xfc346b74
    [5] operator new(0x80, 0x0, 0xd3a18, 0x759c74, 0x0, 0x8345fc), at 0x760c10
    [6] strstreambuf::overflow(0xf41f6e28, 0x29, 0xf41f6e28, 0x39fe0e88, 0x39fe0e88, 0x8345fc), at 0x75bb1c
    [7] streambuf::xsputn(0xf41f6e28, 0xfee00bc0, 0x1, 0x0, 0x81010100, 0x1), at 0x75ab94
    [8] unsafe_ostream::outstr(0xf41f6e78, 0xfee00bbf, 0x0, 0x0, 0xf41f6e7c, 0xfffffffe), at 0x757bac
    =>[9] unsafe_ostream::operator<<(this = 0xf41f6e78, _s = 0xfee00bbf ")"), line 1211 in "iostream.h"
    [10] ostream::operator<<(this = 0xf41f6e74, _s = 0xfee00bbf ")"), line 1350 in "iostream.h"
    [11] CorInterfaceEntity::ifState(this = 0x1bc3de78, newState = MISMATCH_OF_INSTALLED_AND_EXPECTED, needToSendEvent = false
    Can somebody help me giving a direction of investigation ?
    Is there perhaps known problem with iostream on Sun Studio 8 running on Solaris 9 ?
    Thanks for any tips.
    Yaakov Berkovitch
    [email protected]

    But sorry for my insistence, but do you think that
    purify or/and runtime are not able to detect any
    corruption of the heap ?They can detect some kinds of corruption, such as some uses of an invalid pointer.
    But a wild pointer that changes the value of data that is part of your program cannot be detected by RTC or Purify. Those programs can't know whether that change is intentional.
    >
    BTW, we are not using any volatile declaration, and weIf non-local data is shared among threads, it should be declared volatile. For example, suppose you have
    x = foo;
    ... // code not changing foo
    y = foo;
    If foo is not marked volatile, the compiler is allowed to assume its value hasn't changed, and assign to y the same value assigned to x. If foo was changed by another thread, y will not have the current value of foo. The "volatile" declaration says that the variable's value might change without any obvious reason, and the compiler should generate code to load a fresh value each time it is referenced.
    are using the rwtools library packaged with the
    compiler, and are not using the STD library.OK, you are not running into a std::string synchronization bug.
    >
    Also about the compiler option -xarch=v8, is probably
    not relevant for us because we are running Solaris 9.
    So the relevant compiler is probably -xarch=v9. Do you
    advise us using this option ?I think you misunderstand. The -xarch values refer to the kind of processor your program will run on.
    The -xarch=v8 option generates 32-bit code that will run on all SPARC chips, including the chips found in very old SPARCstations. This option is the default for compilers prior to Sun Studio 9 (which ships this week).
    The -xarch=v8plus option generates 32-bit code that runs only on UltraSPARC chips, found in Ultra workstations. These are the only kinds of workstations shipped by Sun since about 1996. Unless you need to support the ancient SPARCstations, we recommend compiling with -xarch=v8plus, to get smaller and faster code.
    The -xarch=v9 option generates 64-bit code that runs only on UltraSPARC chips, an only on Solaris 7 or later. Unless your program requires a very large address space, you generally don't want to generate 64-bit code. On SPARC, 64-bit code is larger and slower than 32-bit code. (Type "long" and all pointers are 64 bits instead of 32 bits.)
    >
    Also I want to return you two new questions:
    1) I read in another discussion,
    http://forum.sun.com/thread.jsp?forum=5&thread=18124&me
    sage=47854#47854
    that another memory manager can be more efficient in
    multi-threaded environment (libmtmalloc.so), and also
    an alternate threads library (/usr/lib/lwp) that
    reduced CPU usage. Do you advice us using this
    alternate library ?The libmtmalloc library usually has better performance in MT programs than the default version of malloc. It also can result in more memory fragmentation. In that case, the larger working set can sometimes have a large negative effect, more than offsetting the MT efficiency. You have to experiment to see whether it is appropriate for your particlular program. If you are running into heap corruption, the pattern of corruption will probably be different with libmtmalloc than with the default malloc. The differences might provide a clue to what is wrong.
    The alternative "T2" threads library was introduced in Solaris 8 as an option.
    In Solaris 9 it is the default, so you are already using it.
    >
    2) We are using the Rogue Wave library shiped with the
    compiler. Is it an up-to-date version ? Can we assume
    that is a good choice or it will be preferable to move
    to the STD library ?I assume you mean Rogue Wave Tools.h++. As explained in the compiler docs, this version of Tools is obsolete, and has not been supported for many years. We continue to provide it for customers who used it before the introduction of the C++ Standard Library in 1998, and who don't want to change their code. We do not recommend it for use in new code.

  • Using JMF API with Sun One Studio v4 update 1 (community ed.)

    Having great difficulty trying to utilise the JMF API I've just downloaded with Sun One Studio v4, update 1 (community edition).
    After installing the API, I tried copying the the .jar files under the lib folder of JMF to the lib folder of sun one studio.
    Although admittedly a novice in the field of adding API's I have attempted to add the .jar files into the libary of recognised modules but made no progress.
    The problem is that although JMF API is installed, Sun One Studio does not seem to be aware of this and so does not recognise any associated libraries e.g. java.media or JMFApplet.
    I would appreciate advice from anyone who knows how to configure Sun One Studio to utilise the JMF API.
    Mark

    All right, I think I may have solved it. After mounting jmf.jar I needed to update the parser database. All the libraries seem to be there.
    Can someone clarify though, the trial program i'm using makes reference to: java.media
    I don't have this module. I do instead have javax.media which I believe includes all the methods of the java version. Am I right or am I missing this crucial module??

  • Need help building boost_1_37_0 on Solaris 10 U6 with Sun Studio 12

    Hi,
    Ok, please bear with me here. I've tried many different sets of instructions, and haven't had success with any of them (including the ones at http://blogs.sun.com/sga/category/Boost).
    Operating System: Solaris 10 x86 U6
    Compiler: Sun Studio 12 (SUNCC version 5.9)
    Boost version: 1.37.0
    The ONLY part of boost that I need is regex. I've never built external libraries before and building boost on Solaris seems a rather daunting task. So, could someone please explain, as clearly as possible, how do I build the boost::regex library using SUNCC?
    I know this is a very broad topic, but since I haven't had any luck with any existing instructions that google turns up, alas I am here.
    Thanks in advance if someone can help me,
    ~Slow
    Note: I don't need any special options, any special, non-standard install paths, nothing. Just a straight, stock, boost install.
    Edited by: SlowToady on Nov 10, 2008 2:18 PM

    First, be sure you have the current patches for Sun Studio 12. You can get them here:
    http://developers.sun.com/sunstudio/downloads/patches/
    Please install the current C++ compiler patch, the C compiler patch, and the common back-end compiler patch.
    You should then be able to build BOOST 1.37.0. The only problem I know of has been filed as CR 6767881, which results in an incorrect complaint about a constructor not being accessible. But I don't think that one affects regex.
    If you running into some other problem after patching the compiler, please post enough detail that we can investigate it.
    Questions about how to build just a portion of BOOST are probably best addressed to a BOOST forum.

  • GUI tools availabe with sun studio 11

    I have used sun workshop v5 for a good number of years and am happy with the GUI based tools I use for debugging C, Fortan and soon Ada code whcih link with dbx and emacs.
    I have had a trawl through the website but haven't found what I;m looking for.
    so the question is : what are the GUI based tools which I could use with sunstudio 11 which will give similar capability to that availabe with sun workshop v5 ?
    regards
    bladerunner

    I guess the base tools in Workshop 5 you mentioned are IDE, dbx. Sun Studio 11 has all of those functions which are much more far better than Workshop 5. The only missing from Sun Studio 11 IDE is project function. It will be back in next release. Take a look at Sun Studio matrix page to see which function is included in Sun Studio 11. The matrix page does not include WS 5 because this version is 5 years old. Here is the URL
    http://developers.sun.com/prodtech/cc/support/support_matrix.jsp
    -Ngoc

  • How do I use infopath 2013 with visual studio 2013 to modify forms with code?

    Dear all,
    I am using sharepoint online and infopath 2013, I wonder how do I edit infopath 2013 forms with visual studio? When I try to edit form code it says  I need visual studio 2012 and some other tools, I installed them and visual studio 2013, I wonder how
    do I get rid of the message and start coding? Can someone provide a detailed procedure of doing so? I am having trouble with creating multiple items with single infopath form with repeating table on sharepoint online. Thanks.
    Timothy

    Hi,
    According to your post, my understanding is that you want to create InfoPath form with code using Visual Studio.
    More information about develop InfoPath form with Visual Studio:
    http://msdn.microsoft.com/en-us/library/office/ee526362(v=office.15).aspx
    http://msdn.microsoft.com/en-us/library/office/aa942693.aspx  
    For the second question, I suggest you can create another post , it will be easier for others to focus on one question in one thread.
    Best regards

  • Use of Threads with JSP's

    Can you use threads in a web application that uses JSP's plus Servlets and Beans ?
    We have a JRUN 3.1 application using JSPs, Servlets and Beans. Shortly after we went live it became apparent that any 2 users using the same object experienced problems as one object was overwriting another. In a panic the problem was solved by whacking SYNCHRONISED on all objects.
    Now we want to write another application, are there strategies for using Threads with JSPs?
    Would this be part of the webserver configuration or would the application be coded in a certain way ?
    Please can you give me a simplistic answer or point me to some documentation that gives a simple overview.
    Thanks Steve

    Hi,
    You can use thread with jsp, i am sending u a example
    package thread;
    import java.io.Serializable;
    public class TaskBean implements Runnable, Serializable {
    private int counter;
    private int sum;
    private boolean started;
    private boolean running;
    private int sleep;
    public TaskBean() {
    counter = 0;
    sum = 0;
    started = false;
    running = false;
    sleep = 100;
    protected void work() {
    try {
    Thread.sleep(sleep);
    counter++;
    sum += counter;
    } catch (InterruptedException e) {
    setRunning(false);
    public synchronized int getPercent() {
    return counter;
    public synchronized boolean isStarted() {
    return started;
    public synchronized boolean isCompleted() {
    return counter == 100;
    public synchronized boolean isRunning() {
    return running;
    public synchronized void setRunning(boolean running) {
    this.running = running;
    if (running)
    started = true;
    public synchronized Object getResult() {
    if (isCompleted())
    return new Integer(sum);
    else
    return null;
    public void run() {
    try {
    setRunning(true);
    while (isRunning() && !isCompleted())
    work();
    } finally {
    setRunning(false);
    And JSP page start.jsp
    <% session.removeAttribute("task"); %>
    <jsp:useBean id="task" scope="session"
    class="thread.TaskBean"/>
    <% task.setRunning(true); %>
    <% new Thread(task).start(); %>
    <jsp:forward page="status.jsp"/>
    ///////////////// status .jsp
    <jsp:useBean id="task" scope="session"
    class="thread.TaskBean"/>
    <HTML>
    <HEAD>
    <TITLE>JSP Progress Bar</TITLE>
    <% if (task.isRunning()) { %>
    <SCRIPT LANGUAGE="JavaScript">
    setTimeout("location='status.jsp'", 1000);
    </SCRIPT>
    <% } %>
    </HEAD>
    <BODY>
    <H1 ALIGN="CENTER">JSP Progress Bar</H1>
    <H2 ALIGN="CENTER">
    Result: <%= task.getResult() %><BR>
    <% int percent = task.getPercent(); %>
    <%= percent %>%
    </H2>
    <TABLE WIDTH="60%" ALIGN="CENTER"
    BORDER=1 CELLPADDING=0 CELLSPACING=2>
    <TR>
    <% for (int i = 10; i <= percent; i += 10) { %>
    <TD WIDTH="10%" BGCOLOR="#000080"> </TD>
    <% } %>
    <% for (int i = 100; i > percent; i -= 10) { %>
    <TD WIDTH="10%"> </TD>
    <% } %>
    </TR>
    </TABLE>
    <TABLE WIDTH="100%" BORDER=0 CELLPADDING=0 CELLSPACING=0>
    <TR>
    <TD ALIGN="CENTER">
    <% if (task.isRunning()) { %>
    Running
    <% } else { %>
    <% if (task.isCompleted()) { %>
    Completed
    <% } else if (!task.isStarted()) { %>
    Not Started
    <% } else { %>
    Stopped
    <% } %>
    <% } %>
    </TD>
    </TR>
    <TR>
    <TD ALIGN="CENTER">
    <BR>
    <% if (task.isRunning()) { %>
    <FORM METHOD="GET" ACTION="stop.jsp">
    <INPUT TYPE="SUBMIT" VALUE="Stop">
    </FORM>
    <% } else { %>
    <FORM METHOD="GET" ACTION="start.jsp">
    <INPUT TYPE="SUBMIT" VALUE="Start">
    </FORM>
    <% } %>
    </TD>
    </TR>
    </TABLE>
    </BODY>
    </HTML>
    ////////////////////////////// stop.jsp
    <jsp:useBean id="task" scope="session"
    class="thread.TaskBean"/>
    <% task.setRunning(false); %>
    <jsp:forward page="status.jsp"/>
    deploy it into ur server and run start.jsp
    and see whatb happens

  • Interpretation of the use of threads with Sessions in the JMS Specification

    Hello,
    I’ve been interacting with two JMS Providers which do a different interpretation of the JMS Specification with the use of different threads for accessing to a session and session’s related objects.
    The question is:
    When a client is consuming messages asynchronously, is it possible to access session’s related objects from a thread different to the one dedicated to the asynchronous consumption, on (thread of control)?
    -     Never?
    -     Yes, but the client should provide explicit synchronization.?
    Our execution scenario is:
    1.- Messages are consumed asynchronously from a dedicated thread.
    2.- From other thread, messages consumed are acknowledged.
    In the JMS specification there is, at least, two parts where this issue is treated:
    1.- The first one (4.4.1 - page 60):
    +“There are no restrictions on the number of threads that can use a Session object or those it creates. The restriction is that the resources of a Session should not be used concurrently by multiple threads. It is up to the user to insure that this concurrency restriction is met. The simplest way to do this is to use one thread. In the case of asynchronous delivery, use one thread for setup in stopped mode and then start asynchronous delivery. In more complex cases the user must provide explicit synchronization.”+
    This extract, makes me think that it is possible the access from different threads, but If I do that, I should provide explicit synchronization.
    2.- The second one (4.4.6 – page 62,63)
    +"Once a connection has been started, any session with a registered message listener(s) is dedicated to the thread of control that delivers messages to it. It is erroneous for client code to use this session or any of its constituent objects from another thread of control. The only exception to this is the use of the session or connection close method"?+
    This extract, could be interpreted as that the concurrent access is never allowed in the described situation.

    I think the key words are in 4.4.6 (and also the javadoc for Session): "Once a connection has been started, any session with a registered message listener(s) is dedicated to the thread of control that delivers messages to it".
    My interpretation of this is that you when you register a message listener and call connection.start(), the thread which delivers messages to the listener should be thought of as "using the resources of the session" (as mentioned in 4.4.1) continuously until the connection is stopped (or until the session or connection is closed). it doesn't matter whether the session is executing onMessage() or not.
    Given this, both 4.4.1 and 4.4.6 say the same thing: that once you have registered and started a message listener, the only thing you can do to the session from another thread is to close it.
    I agree the spec could be clearer. In particular the words "In more complex cases the user must provide explicit synchronization" in 4.4.6 should be clarified to state what this actually means rather than give a hint.
    Please note that work has just started on updating the JMS specification, so now is a great time to report areas of the JMS spec which would benefit from clarification. If you'd like this to be considered for clarification, please report it in the official JSR 343 issue tracker at http://jms-spec.java.net
    Nigel

  • Error building using Coverity Prevent and Sun Studio 11

    We recently started using a static code-checking tool called Coverity Prevent. When we first started using it, we were on a very old verison of the Forte Compiler (Forte 6 update 2). Builds completed fine through Prevent. In the last month, we've upgraded to Sun Studio 11 (can't go to 12 because we're using Solaris 8). Now I can't get a build to run completely through Prevent. Prevent has a preprocessor that's a bit more strict than most compilers. I'm getting the following errors in a lot of places.
    "/vobs1/cots/ForteDeveloper/SUNWspro/prod/include/CC/rw7/rw/defs.h", line 316: error #101:
    "istream" has already been declared in the current scope
    class _RWCLASSTYPE istream;
    ^
    "/vobs1/cots/ForteDeveloper/SUNWspro/prod/include/CC/rw7/rw/defs.h", line 317: error #101:
    "ostream" has already been declared in the current scope
    class _RWCLASSTYPE ostream;
    ^
    "/vobs1/cots/ForteDeveloper/SUNWspro/prod/include/CC/rw7/rw/defs.h", line 318: error #101:
    "ios" has already been declared in the current scope
    class _RWCLASSTYPE ios;
    ^
    "/vobs1/cots/ForteDeveloper/SUNWspro/prod/include/CC/Cstd/iostream.h", line 4: error #101:
    "istream" has already been declared in the current scope
    using std::istream;
    ^
    "/vobs1/cots/ForteDeveloper/SUNWspro/prod/include/CC/Cstd/iostream.h", line 9: error #101:
    "ostream" has already been declared in the current scope
    using std::ostream;
    ^
    I've googled a bit, and most of the solutions involve someone mistakenly putting "using namespace std" in a header file. I can't find any case where we do this in our code. One specific file that is failing includes one local header, and that header only includes <fstream.h> and <rw/cstring.h>. It seems like RW and std are conflicting with each other somewhere, but I can't figure out where. The compiler command looks like:
    /vobs1/cots/ForteDeveloper/SUNWspro/bin/CC -xildoff -instances=static -mt -g -fsimple
    -xlibmil -xO3 -xtarget=ultra -DUSE_VFU_LL_C -DXRT -KPIC -library=rwtools7_std -x
    libmopt -DRW_MULTI_THREAD -I/vobs1/cots/rogue/workspaces/SOLARIS7/SUNPRO50/12d -c c4i_file_stream.cpp
    We're still pointing at an older version of RW for the DBTools libraries (rebuilt using the compiler's internal Tools++), but we're using the compiler's internal Tools++ headers and libraries for everything else.

    It sounds like Prevent is not processing the #include directives, or possibly some other preprocessing directives, the same way as the Sun C++ compiler.
    The C++ Users Guide documents how #include directives are processed, and in particular the order in which directories are searched.
    [http://docs.sun.com/app/docs/doc/819-5267/bkaso?a=view]
    If Prevent provides similar documentation, you can compare the docs. If you see a difference, maybe Prevent has some options to control the behavior to make it work like the Sun compiler.
    Note: The CC driver passes some -I directives to the C++ compiler proper (ccfe) that do not appear on the CC command line that you write. The exact -I options depend on other options on the command line. Possibly Prevent is not using the same set of implicit -I directives.
    If you can't resolve the #include directive issue, you might need to talk to Coventry tech support.
    We at Sun are happy to work with 3rd-party vendors to help them get their products working correctly on Sun.

Maybe you are looking for