Commit beadb2a7 authored by Rinus Plasmeijer's avatar Rinus Plasmeijer
Browse files

*** empty log message ***

parent 05aa205d
definition module Semaphore
CreateSemaphore :: !Int !Int !Int !{#Char} !*World -> (!Int,!*World);
WaitForSingleObject :: !Int !Int !*World -> (!Int,!*World);
ReleaseSemaphore :: !Int !Int !Int !*World -> (!Int,!*World);
CloseHandle :: !Int !*World -> (!Int,!*World);
implementation module Semaphore;
import StdEnv;
INFINITE :== -1;
// add CreateSemaphoreA@16 and ReleaseSemaphore@12 to kernel_library for Clean 2.2 and older
CreateSemaphore :: !Int !Int !Int !{#Char} !*World -> (!Int,!*World);
CreateSemaphore semaphoreAttributes initialCount maximumCount name world = code {
ccall CreateSemaphoreA@16 "PIIIs:I:A"
}
WaitForSingleObject :: !Int !Int !*World -> (!Int,!*World);
WaitForSingleObject handle milliseconds world = code {
ccall WaitForSingleObject@8 "PII:I:A"
}
ReleaseSemaphore :: !Int !Int !Int !*World -> (!Int,!*World);
ReleaseSemaphore semaphore releaseCount previousCount_p world = code {
ccall ReleaseSemaphore@12 "PIII:I:A"
}
CloseHandle :: !Int !*World -> (!Int,!*World);
CloseHandle handle world = code {
ccall CloseHandle@4 "PI:I:A"
}
Start w
# semaphore_name = "MySemaphoreName";
# (semaphore,world) = CreateSemaphore 0 1 1 semaphore_name w;
| semaphore==0
= abort "CreateSemaphore failed";
# (r,world) = WaitForSingleObject semaphore INFINITE world;
# (stdout,world) = stdio world;
# (ok,c,stdout) = freadc stdout;
# (ok,world) = fclose stdout world;
# (ok,world) = ReleaseSemaphore semaphore 1 0 world;
# (ok,world) = CloseHandle semaphore world;
| ok==0
= abort "CloseHandle failed";
......@@ -16,7 +16,7 @@ import httpUtil
:: Socket :== Int;
//required functions
RegisterSubProcToServer :: !Int !Int !Int !String !String -> Int
RegisterSubProcToServer :: !Int !Int !Int !String !String -> Int // priority minimum maximum number of subservers
WaitForMessageLoop :: ([String] Int Socket *World -> (Socket,*World)) Socket !*World -> *World
//helper-functions for sending (suggested to use one of these)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment