Module ThreadUnix
Contents
Instructions: Use this module in your project
In the IDE (CLion, Visual Studio Code, Xcode, etc.) you use for your DkSDK project:
Add the following to your project's
dependencies/CMakeLists.txt
:DkSDKProject_DeclareAvailable(ocaml CONSTRAINT "= 4.14.0" FINDLIBS str unix runtime_events threads dynlink) DkSDKProject_MakeAvailable(ocaml)
Add the
Findlib::ocaml
library to any desired targets insrc/*/CMakeLists.txt
:target_link_libraries(YourPackage_YourLibraryName # ... existing libraries, if any ... Findlib::ocaml)
Click your IDE's
Build
button
Not using DkSDK?
FIRST, do one or all of the following:
Run:
opam install ocaml.4.14.0
Edit your
dune-project
and add:(package (name YourExistingPackage) (depends ; ... existing dependenices ... (ocaml (>= 4.14.0))))
Then run:
dune build *.opam # if this fails, run: dune build
Edit your
<package>.opam
file and add:depends: [ # ... existing dependencies ... "ocaml" {>= "4.14.0"} ]
Then run:
opam install . --deps-only
FINALLY, add the unix threads
library to any desired (library)
and/or (executable)
targets in your **/dune
files:
(library
(name YourLibrary)
; ... existing library options ...
(libraries
; ... existing libraries ...
unix threads))
(executable
(name YourExecutable)
; ... existing executable options ...
(libraries
; ... existing libraries ...
unix threads))
Process handling
val
execv : ``string
->
``string array``
->
unit
val
execve : ``string
->
``string array``
->
``string array``
->
unit
val
execvp : ``string
->
``string array``
->
unit
val
wait : ``unit
->
int *
Unix.process_status
val
waitpid :
Unix.wait_flag
list``
->
``int
->
int *
Unix.process_status
val
system : ``string
->
Unix.process_status
Basic input/output
val
read :
Unix.file_descr
->
``bytes
->
``int
->
``int
->
int
val
write :
Unix.file_descr
->
``bytes
->
``int
->
``int
->
int
val
write_substring :
Unix.file_descr
->
``string
->
``int
->
``int
->
int
Input/output with timeout
val
timed_read :
Unix.file_descr
->
``bytes
->
``int
->
``int
->
``float
->
int
val
timed_write :
Unix.file_descr
->
``bytes
->
``int
->
``int
->
``float
->
int
Behave as ThreadUnix.read
and
ThreadUnix.write
, except that
Unix_error(ETIMEDOUT,_,_)
is raised if no data is available for
reading or ready for writing after d
seconds. The delay d
is given
in the fifth argument, in seconds.
val
timed_write_substring :
Unix.file_descr
->
``string
->
``int
->
``int
->
``float
->
int
Polling
val
select :
Unix.file_descr
list``
->
Unix.file_descr
list``
->
Unix.file_descr
list``
->
``float
->
Unix.file_descr
list`` *
Unix.file_descr
list`` *
Unix.file_descr
list
Pipes and redirections
val
pipe : ``?cloexec:bool
->
``unit
->
Unix.file_descr
*
Unix.file_descr
val
open_process_in : ``string
->
in_channel
val
open_process_out : ``string
->
out_channel
val
open_process : ``string
->
in_channel
*
out_channel
Time
val
sleep : ``int
->
unit
Sockets
val
socket : ``?cloexec:bool
->
Unix.socket_domain
->
Unix.socket_type
->
``int
->
Unix.file_descr
val
accept : ``?cloexec:bool
->
Unix.file_descr
->
Unix.file_descr
*
Unix.sockaddr
val
connect :
Unix.file_descr
->
Unix.sockaddr
->
unit
val
recv :
Unix.file_descr
->
``bytes
->
``int
->
``int
->
Unix.msg_flag
list``
->
int
val
recvfrom :
Unix.file_descr
->
``bytes
->
``int
->
``int
->
Unix.msg_flag
list``
->
int *
Unix.sockaddr
val
send :
Unix.file_descr
->
``bytes
->
``int
->
``int
->
Unix.msg_flag
list``
->
int
val
send_substring :
Unix.file_descr
->
``string
->
``int
->
``int
->
Unix.msg_flag
list``
->
int
val
sendto :
Unix.file_descr
->
``bytes
->
``int
->
``int
->
Unix.msg_flag
list``
->
Unix.sockaddr
->
int
val
sendto_substring :
Unix.file_descr
->
``string
->
``int
->
``int
->
Unix.msg_flag
list``
->
Unix.sockaddr
->
int
val
open_connection :
Unix.sockaddr
->
in_channel
*
out_channel