Skip to content

Commit 826605c

Browse files
committed
add POST
1 parent a88a907 commit 826605c

3 files changed

Lines changed: 45 additions & 25 deletions

File tree

content/posts/java-dsf.md

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@ Explain how to use the DSF.
1515
[Refer1](https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.cdt.doc.isv%2Fguide%2Fdsf%2Fintro%2Fdsf_programming_intro.html)
1616
<br>
1717

18+
![image](/images/dsf_overview.png)
19+
1820
## 1. Introduction
19-
- Scenario: Debugger View Fetching Data
21+
- Scenario: **Debugger View Fetching Data**
2022
Context: We want to show variable values in the Variables View as the user steps through the code.
2123

22-
- **Asynchronous**
23-
- When the user steps through the program, the debugger needs to **fetch variable values** from the target (like a remote system). This operation might **take a few milliseconds or more**, depending on the connection. If we **block the UI thread, the UI freezes**.
24+
### 1.1. **Asynchronous**
25+
- Req: When the user steps through the program, the debugger needs to **fetch variable values** from the target (like a remote system). This operation might **take a few milliseconds or more**, depending on the connection. If we **block the UI thread, the UI freezes**.
2426
- Solution: Use an asynchronous method to fetch variable data
2527

2628
```java
@@ -38,17 +40,17 @@ void getVariableValue(String varName, DataRequestMonitor<String> rm) {
3840
- Prevents blocking the UI.
3941
- Allows the Eclipse debug framework to continue updating other views.
4042

41-
- **Synchronous**
42-
- We want to implement a feature like evaluate expression that requires the value immediately. We don’t want to rewrite your entire logic using async callbacks just to get the result of getVariableValue().
43+
### 1.2. **Synchronous**
44+
- We want to implement a feature like **evaluate expression** that requires the value immediately. We don’t want to rewrite your entire logic using async callbacks just to get the result of getVariableValue().
4345

44-
- Solution: Use a DSF Query to wrap the async call in a synchronous interface:
46+
- Solution: Use a DSF Query to **wrap the async call in a synchronous interface**:
4547

4648
```java
4749
String getVariableValueSync(String varName) {
4850
Query<String> query = new Query<>() {
4951
@Override
5052
protected void execute(DataRequestMonitor<String> rm) {
51-
getVariableValue(varName, rm); // Asynchronous method
53+
getVariableValue(varName, rm); // Wrap Asynchronous method
5254
}
5355
};
5456

@@ -66,25 +68,35 @@ String getVariableValueSync(String varName) {
6668
- Some contexts expect a result immediately.
6769
- Simplifies logic when integrating with legacy synchronous systems.
6870

69-
- Summary Table:
71+
### 1.3. Summary Table:
72+
7073
|Use Case | Method Type | Reason |
7174
|---------|-------------|----------|
72-
|Fetching variable values in UI| Asynchronous| Avoid blocking UI thread|
73-
|Evaluating expressions in scripts| Synchronous| Scripts expect immediate result|
74-
|Performing batch operations| Asynchronous| Can parallelize or chain operations|
75+
|Fetching variable values in UI| **Asynchronous**| Avoid blocking UI thread|
76+
|Nested UI event (e.g., button click)| **Asynchronous**| Keeps UI responsive|
77+
|Performing batch operations| **Asynchronous**| Can parallelize or chain operations|
7578
|Calling legacy blocking logic| Synchronous| Synchronous integration is easier|
76-
|Nested UI event (e.g., button click)| Asynchronous| Keeps UI responsive|
79+
|Evaluating expressions in scripts| Synchronous| Scripts expect immediate result|
7780

7881
## 2. Asynchronous Methods: Request Monitor , Data Request Monitor, Multi-Request Monitor
79-
- There is an standard callback object used in DSF, the request monitor, has following features:
80-
- Executor
81-
- Status
82-
- Callback methods: handleCompleted(), handleOK(), handleError(),...
83-
- Parent request monitor
82+
- `Async methods is a way that use a callback object to indicate their completion`.
83+
84+
## 2.1. Request Monitor
85+
- There is an standard **callback object** used in DSF, the request monitor, has following features:
86+
- **Executor**: executor to invoke the callback method
87+
- **Status**: indicating the success or failure of the callback method
88+
- **Callback methods**: methods which are invoked when the callback is invoked: handleCompleted(), handleOK(), handleError(),... -> overwrite these if need to perform additional process after async method completion.
89+
- **Parent request monitor**:
8490
- Returning values to the caller. ( Data Request Monitor)
8591
- Done count. (Multi-Request Monitor)
8692

87-
- Examples:
93+
## 2.2. Data Request Monitor
94+
- The **Request Monitor** can return status of the async method but do not return a value to caller. **Data Request Monitor** can be used for that purpose.
95+
96+
## 2.3. Counting Request Monitor
97+
- When we need to manage the completion of several request monitor. It is configured such that it's done() method needs to be called a count number of times before the callback method is invoked.
98+
99+
## 2.4 Examples:
88100
```java
89101
import java.util.concurrent.Executor;
90102

@@ -98,15 +110,15 @@ public class Test {
98110
Executor executor = ImmediateExecutor.getInstance(); // Get the Executor
99111
RequestMonitor rm1 = new RequestMonitor(executor, null) {
100112
@Override
101-
protected void handleCompleted() {
113+
protected void handleCompleted() { // callback function
102114
System.out.println("Fcn1 has done");
103115
}
104116
};
105117
asyncFcn1(rm1);
106118

107119
DataRequestMonitor<Integer> rm2 = new DataRequestMonitor<>(executor, null) {
108120
@Override
109-
protected void handleCompleted() {
121+
protected void handleCompleted() { // callback function
110122
Integer data = getData();
111123
System.out.println("Fcn2 has done");
112124
System.out.println("Returned data: " + data);
@@ -117,7 +129,7 @@ public class Test {
117129

118130
static void asyncFcn1(RequestMonitor rm) {
119131
System.out.println("Run Fcn1");
120-
rm.done();
132+
rm.done(); // notify that the async method done -> will run the callback function
121133
}
122134

123135
static void asyncFcn2(int value, DataRequestMonitor<Integer> rm) {
@@ -137,9 +149,9 @@ Fcn2 has done
137149
Returned data: 2
138150
```
139151

140-
## 3. Concurrent
152+
## 3. Concurrency
141153
### 3.1. Query ( implements Runnable)
142-
- Using a query can use a execute() implementation in order to call other asynchronous method.
154+
- Using a Query can use a execute() (overwrite) implementation in order **to call other asynchronous method** from a **sync method**
143155
```java
144156

145157
import java.util.concurrent.Executor;
@@ -156,13 +168,13 @@ public class TestQuery {
156168
System.out.println("Result: " + result); // Expected output: Result: 5
157169
}
158170

159-
// Asynchronous addition method ( fetch value etc, take more time here)
171+
// Asynchronous method ( fetch value etc, take more time here)
160172
static void asyncAdd(int a, int b, DataRequestMonitor<Integer> rm) {
161173
rm.setData(a + b);
162174
rm.done();
163175
}
164176

165-
// Synchronous method using DSF Query
177+
// Synchronous method using DSF Query to call a async method
166178
static int syncAdd(final int a, final int b, final Executor executor) {
167179
Query<Integer> query = new Query<>() {
168180
@Override
@@ -185,4 +197,11 @@ public class TestQuery {
185197
```
186198

187199
### 3.2. Synchronization
200+
- DSF uses a single-threaded executor (DSF Executor thread) as the primary mechanism for safe access to date. (race conditions + deadlocks)
201+
202+
### 3.3. Annotations
203+
- DSF defines a number of annotations that can be used to determine what are the rules governing access to the various data objects.
204+
205+
## 4. Services
206+
### 4.1. OSGi
188207

content/posts/maven-tycho.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ weight: 22 # The order in which the post appears in a list of posts. Lower nu
1313
---
1414

1515
Introducing about Maven and how to use Maven Tycho plugin to build plugins into the SNAPSHOT
16+
1617
[Refer1](https://www.vogella.com/tutorials/EclipseTycho/article.html)<br>
1718
[Refer2](https://www.vogella.com/tutorials/ApacheMaven/article.html)<br>
1819
[Refer3](https://www.vogella.com/tutorials/EclipseMaven/article.html)<br>

static/images/dsf_overview.png

19.1 KB
Loading

0 commit comments

Comments
 (0)