• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to use “unsafe” in JNI?  RSS feed

 
Roger Krampfer
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's say I have a value pointed to by a (base,offset) tuple.

e.g.



(runnable version: https://ideone.com/OasQrh )

I now want to execute



in `C`.

Why? Because a different process may move the data and change``base`` and ``off`` to point to the new location. I want to make use of intel RTM to make sure moving the data does not interfere with regular accesses to the field.

So let's create a new class



and replace



we run this through javah to get the header, copy the method signatures to an ``RTM_transct.cpp`` and get something like


The "heart" of the transaction are these three lines that (are supposed to)
correspond to what Accessor used to do:



)

Ideally, of course, I'd like to do something akin to ``base[offset] = value``, but I very much doubt that would work.

What do I put here for unsafe.setInt?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!