1
0
mirror of https://github.com/aziascreations/BakaShrot.git synced 2026-11-23 20:58:46 +01:00

Moved the PureBasic version to OldSource/, Started the Rust rewrite in Source/

The rewrite's plan and decisions are in revamp.md. Steps 0 to 10 are done:
the workspace and checks, bakashrot-proto, bakashrot-pki and
bakashrot-cert, bakashrot-config, bakashrot-storage (schema v9), the
server and the client library (every request but replication's,
attachments and retention included), the C DLL with its C, PureBasic and
Python bindings, and the bakashrot tool. Step 11 (replication) is next.

OldSource/ is the old implementation, kept building and passing as the
reference.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RwFeVTGs2SsufaH6zquzcb
This commit is contained in:
2026-11-14 12:47:40 +01:00
parent d0048b17c8
commit e044fcf359
225 changed files with 21849 additions and 123 deletions
+86
View File
@@ -0,0 +1,86 @@
;{- Code Header
; ==- Basic Info -================================
; Name: Signal.pbi
; Version: 0.0.1
; Author: Herwin Bozet (NibblePoker)
;
; ==- Compatibility -=============================
; Tested compiler versions:
; * PureBasic 5.73 LTS (Windows x64, Linux x64)
; * PureBasic 6.40 C Backend (Windows x64)
; * PureBasic 6.41 (Linux x64)
; * PureBasic 6.41 C Backend (Linux x64)
;
; ==- Links -=====================================
; GitHub: https://github.com/aziascreations/BakaShrot
;}
; ============================================================================
; BakaShrot Signal
;
; Wakes up a thread waiting for something, instead of it polling with Delay():
; Waiter: BakaShrot_Signal_Wait(Signal, TimeoutMs), then checks for work.
; Waker: does the work's setup, then BakaShrot_Signal_Set(Signal).
; Signals don't stack: several Set() before a Wait() wake it once, so the
; waiter must handle everything that's there once woken. A Set() before the
; Wait() isn't lost, the Wait() returns right away.
;
; Windows: an auto-reset event. Elsewhere: a semaphore polled every ms, until
; something better is needed there.
; ============================================================================
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
; Returns 0 on failure.
Procedure.i BakaShrot_Signal_Create()
; Auto-reset, not set.
ProcedureReturn CreateEvent_(0, #False, #False, 0)
EndProcedure
Procedure BakaShrot_Signal_Set(Signal.i)
SetEvent_(Signal)
EndProcedure
; Waits until Signal is set, for up to TimeoutMs.
; Returns #True if it was set, #False if it timed out.
Procedure.i BakaShrot_Signal_Wait(Signal.i, TimeoutMs.i)
; WAIT_OBJECT_0
ProcedureReturn Bool(WaitForSingleObject_(Signal, TimeoutMs) = 0)
EndProcedure
Procedure BakaShrot_Signal_Free(Signal.i)
CloseHandle_(Signal)
EndProcedure
CompilerElse
Procedure.i BakaShrot_Signal_Create()
ProcedureReturn CreateSemaphore(0)
EndProcedure
Procedure BakaShrot_Signal_Set(Signal.i)
SignalSemaphore(Signal)
EndProcedure
Procedure.i BakaShrot_Signal_Wait(Signal.i, TimeoutMs.i)
Protected StartTime.i = ElapsedMilliseconds()
Repeat
If TrySemaphore(Signal)
; Doesn't stack, like the Windows version.
While TrySemaphore(Signal)
Wend
ProcedureReturn #True
EndIf
If ElapsedMilliseconds() - StartTime >= TimeoutMs
ProcedureReturn #False
EndIf
Delay(1)
ForEver
EndProcedure
Procedure BakaShrot_Signal_Free(Signal.i)
FreeSemaphore(Signal)
EndProcedure
CompilerEndIf