Skip to content

Commit 3e33da2

Browse files
fix: address code review feedback
- Fix release-plugin.yml condition to handle workflow_dispatch events - Correct JObjectPool constructor signature (maxSize, not createFunc) - Fix JAction state parameter docs (value types work without boxing) - Update README AI feature wording for better clarity Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: JasonXuDeveloper - 傑 <jason@xgamedev.net>
1 parent f1d2277 commit 3e33da2

5 files changed

Lines changed: 30 additions & 30 deletions

File tree

.github/workflows/release-plugin.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ on:
2121
jobs:
2222
release-plugin:
2323
runs-on: ubuntu-latest
24-
# Skip if this is an automated version bump commit
25-
if: "!contains(github.event.head_commit.message, 'chore(plugin): bump version')"
24+
# Skip if this is an automated version bump commit (only applies to push events)
25+
if: github.event_name == 'workflow_dispatch' || !contains(github.event.head_commit.message || '', 'chore(plugin): bump version')
2626
steps:
2727
- uses: actions/checkout@v4
2828
with:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
- **Zero/Minimal GC** - UniTask (GC-free async) + Nino (high-performance serialization)
1919
- **All Platforms** - iOS, Android, Windows, macOS, WebGL, WeChat, Douyin, Alipay, TapTap
2020
- **Secure Updates** - Obfuscate hot update DLL + encrypt resources (assets & DLL/PDB) with XOR/AES/ChaCha20
21-
- **AI-Ready** - AI coding assistants [automatically discover and apply](claude-plugin/) JEngine APIs as you code
21+
- **AI-Accelerated** - Intelligent AI [seamlessly integrated](claude-plugin/), deeply understands JEngine to boost productivity
2222
- **Commercial Ready** - Production-proven by individuals and enterprise teams
2323

2424
## Overview

README_zh_cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
- **零/极低GC** - UniTask(无GC异步)+ Nino(高性能序列化)
1919
- **全平台支持** - iOS、Android、Windows、macOS、WebGL、微信、抖音、支付宝、TapTap
2020
- **安全更新** - 热更DLL混淆 + 资源(资产和DLL/PDB)支持XOR/AES/ChaCha20加密
21-
- **AI就绪** - AI编码助手[自动发现并运用](claude-plugin/)JEngine的API和模式
21+
- **AI赋能** - AI[深度理解JEngine](claude-plugin/),无缝融入开发流程,效率倍增
2222
- **商用验证** - 经个人和企业团队生产环境验证
2323

2424
## 概述

claude-plugin/skills/jaction/SKILL.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,19 @@ await JAction.Create()
7373
.ExecuteAsync();
7474
```
7575

76-
### State Parameter for Zero-Allocation (Reference Types Only)
76+
### State Parameter for Zero-Allocation
7777
```csharp
78-
// CORRECT - no closure allocation
78+
// CORRECT - no closure allocation (works with both reference and value types)
7979
var data = new MyData();
8080
JAction.Create()
8181
.Do(static (MyData d) => d.Process(), data)
8282
.Execute();
8383

84-
// NOTE: State overloads ONLY work with reference types (classes, arrays)
85-
// Value types get boxed, defeating allocation avoidance
84+
// Also works with value types without boxing
85+
int count = 5;
86+
JAction.Create()
87+
.Do(static (int c) => Debug.Log($"Count: {c}"), count)
88+
.Execute();
8689
```
8790

8891
### Set Timeouts for Production
@@ -106,6 +109,5 @@ action.Cancel();
106109
## Common Mistakes
107110
- NOT using `using var` after ExecuteAsync (memory leak, never returns to pool)
108111
- Using Execute() in production (blocks main thread, causes frame drops)
109-
- Using state overloads with value types (causes boxing)
110112
- Forgetting to call Execute() or ExecuteAsync() (nothing happens)
111113
- Code in .Do() runs atomically and cannot be interrupted - keep callbacks lightweight

claude-plugin/skills/jobjectpool/SKILL.md

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,53 +18,49 @@ Thread-safe, lock-free generic object pooling for Unity using CAS operations. Wo
1818
### Constructor
1919
```csharp
2020
new JObjectPool<T>(
21-
Func<T> createFunc = null, // Factory (defaults to Activator.CreateInstance<T>())
22-
Action<T> onRent = null, // Called when renting
23-
Action<T> onReturn = null // Called when returning
21+
int maxSize = 64, // Maximum pooled objects (excess discarded)
22+
Action<T> onRent = null, // Called when renting (for initialization)
23+
Action<T> onReturn = null // Called when returning (for cleanup)
2424
)
2525
```
26+
Note: `T` must be a reference type with a parameterless constructor (`where T : class, new()`).
2627

2728
### Methods
2829
- `.Rent()` - Get object from pool or create new
29-
- `.Return(T obj)` - Return object to pool
30+
- `.Return(T obj)` - Return object to pool (null values ignored)
3031
- `.Clear()` - Remove all pooled objects
31-
- `.Prewarm(int count)` - Pre-allocate objects
32-
- `.Count` - Current available count
32+
- `.Prewarm(int count)` - Pre-allocate objects (won't exceed maxSize)
33+
- `.Count` - Current available count (approximate, thread-safe)
3334

3435
### Static Access
35-
- `JObjectPool.Shared<T>()` - Global shared pool per type (simple objects only)
36+
- `JObjectPool.Shared<T>()` - Global shared pool per type (default config: maxSize=64)
3637

3738
## Patterns
3839

3940
### Basic Pool
4041
```csharp
41-
var pool = new JObjectPool<Bullet>();
42+
var pool = new JObjectPool<Bullet>(maxSize: 100);
4243
var bullet = pool.Rent();
4344
// ... use bullet ...
4445
pool.Return(bullet);
4546
```
4647

47-
### With Custom Factory
48+
### With Initialization on Rent
4849
```csharp
4950
var pool = new JObjectPool<Enemy>(
50-
createFunc: () => new Enemy(defaultHealth: 100)
51+
maxSize: 50,
52+
onRent: static enemy => enemy.Reset()
5153
);
5254
```
5355

5456
### Reset State on Return (RECOMMENDED)
5557
```csharp
5658
var pool = new JObjectPool<List<int>>(
59+
maxSize: 32,
5760
onReturn: static list => list.Clear()
5861
);
5962
```
6063

61-
### Initialize on Rent
62-
```csharp
63-
var pool = new JObjectPool<Projectile>(
64-
onRent: static p => p.Reset()
65-
);
66-
```
67-
6864
### Prewarm During Loading
6965
```csharp
7066
var pool = new JObjectPool<Effect>();
@@ -73,21 +69,23 @@ pool.Prewarm(50); // Pre-create during loading screen
7369

7470
### Shared Pool (Simple Objects)
7571
```csharp
76-
// Good for simple reusable objects without custom initialization
72+
// Good for simple reusable objects without custom callbacks
7773
var sb = JObjectPool.Shared<StringBuilder>().Rent();
7874
sb.Append("Hello");
75+
sb.Clear(); // Clean up before returning
7976
JObjectPool.Shared<StringBuilder>().Return(sb);
8077
```
8178

8279
## Best Practices
8380
1. **Pre-allocate during loading** to prevent in-game allocation spikes
8481
2. **Reset state on return** to prevent data leaks between reuses
85-
3. **Use custom pools** for complex objects requiring specific initialization
86-
4. **Use shared pools only** for simple value objects with default construction
82+
3. **Set appropriate maxSize** based on expected concurrent usage
83+
4. **Use shared pools** for simple objects without custom callbacks
8784
5. **Monitor pool Count** to optimize sizing
8885

8986
## Common Mistakes
9087
- Returning null to pool (ignored, but wasteful)
9188
- Not clearing object state on return (causes bugs from stale data)
9289
- Forgetting to return objects (pool becomes ineffective)
93-
- Using shared pool for complex objects needing initialization
90+
- Setting maxSize too low (causes frequent allocations)
91+
- Setting maxSize too high (wastes memory)

0 commit comments

Comments
 (0)