Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging dev code in main #1

Merged
merged 3 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/BaselineOfPharoZeroMQ/BaselineOfPharoZeroMQ.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Class {
#name : #BaselineOfPharoZeroMQ,
#superclass : #Object,
#category : #BaselineOfPharoZeroMQ
}

{ #category : #baselines }
BaselineOfPharoZeroMQ >> baseline: spec [

<baseline>
spec for: #common do: [

"Packages"
spec package: 'PharoZeroMQ' ]
]
1 change: 1 addition & 0 deletions src/BaselineOfPharoZeroMQ/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : #BaselineOfPharoZeroMQ }
28 changes: 28 additions & 0 deletions src/ZMQ/LibZMQ.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"
ZMQ Library contains the name of the file that has the library.
Exclusively called in ZMQLibraryInterface. To know the version of this lib, you can find out by doing:
ZMQLibraryInterface version.

This library uses UFFI calls.
"
Class {
#name : #LibZMQ,
#superclass : #FFILibrary,
#category : #'ZMQ-Libs'
}

{ #category : #'accessing platform' }
LibZMQ >> macModuleName [
^ 'libzmq.dylib'
]

{ #category : #'accessing platform' }
LibZMQ >> unixModuleName [
^ 'libzmq.so'
]

{ #category : #'accessing platform' }
LibZMQ >> win32ModuleName [
"While this is not a 'libc' properly, msvcrt has the functions we are defining here"
^ 'zmq.dll'
]
41 changes: 41 additions & 0 deletions src/ZMQ/LibZMQThreaded.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"
I am LibZMQ but with a Thread Worker. Warning, I do not support every socket type, being used with an non-thread safe socket might lead to undesired behavior regarding your image.
I am used in only a few methods, there is no point in calling me for short tasks.

To understand how you should use the TFWorker, please check TFTestLibraryUsingWorker.
Collaborators : ZMQLibraryInterface interacts with me .


"
Class {
#name : #LibZMQThreaded,
#superclass : #LibZMQ,
#classInstVars : [
'tfWorker'
],
#category : #'ZMQ-Libs'
}

{ #category : #accessing }
LibZMQThreaded class >> tfWorker [

^ tfWorker
]

{ #category : #accessing }
LibZMQThreaded class >> tfWorker: anObject [

tfWorker := anObject
]

{ #category : #'accessing platform' }
LibZMQThreaded >> calloutAPIClass [

^ TFCalloutAPI
]

{ #category : #'accessing platform' }
LibZMQThreaded >> runner [

^ self class tfWorker
]
17 changes: 17 additions & 0 deletions src/ZMQ/ManifestZMQ.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"
I store metadata for this package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
"
Class {
#name : #ManifestZMQ,
#superclass : #PackageManifest,
#category : #'ZMQ-Manifest'
}

{ #category : #'meta-data' }
ManifestZMQ class >> description [

^ 'ZMQ port from SMOCK.
ZMQ is a library that lets you discuss between 2 interfaces. With Pharo, you can send and receive messages with 2 different images. To do that, it uses a socket system, here is implemented a PUB-SUB and a REQ-REP pattern.
For more information on the library and the use of its functions, visit :
https://zguide.zeromq.org/ '
]
50 changes: 50 additions & 0 deletions src/ZMQ/ZMQConstants.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"
This class initializes the option values for sockets. This pool is shared among each class of ZMQ-Core, Libs and Samples. It is initialized in the new: instance method of ZMQSocket.


"
Class {
#name : #ZMQConstants,
#superclass : #SharedPool,
#classVars : [
'ZMQ_BACKLOG',
'ZMQ_DONTWAIT',
'ZMQ_IMMEDIATE',
'ZMQ_LAST_ENDPOINT',
'ZMQ_PUB',
'ZMQ_RCVMORE',
'ZMQ_REP',
'ZMQ_REQ',
'ZMQ_REQ_RELAXED',
'ZMQ_ROUTING_ID',
'ZMQ_SUB',
'ZMQ_SUBSCRIBE',
'ZMQ_UNSUBSCRIBE',
'ZMQ_WAIT'
],
#category : #'ZMQ-Core'
}

{ #category : #'private - initialization' }
ZMQConstants class >> initConstants [
"Available socket types"

ZMQ_PUB := 1.
ZMQ_REP := 4.
ZMQ_REQ := 3.
ZMQ_SUB := 2.

"Socket options, see zmq.h Socket option list"
ZMQ_SUBSCRIBE := 6.
ZMQ_UNSUBSCRIBE := 7.
ZMQ_LAST_ENDPOINT := 32.
ZMQ_BACKLOG := 19.
ZMQ_REQ_RELAXED := 53.
ZMQ_IMMEDIATE := 39.
ZMQ_RCVMORE := 13.
ZMQ_ROUTING_ID := 5.

"Flags "
ZMQ_DONTWAIT := 1.
ZMQ_WAIT := 0
]
44 changes: 44 additions & 0 deletions src/ZMQ/ZMQContext.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"
A ZMQ context is a container for all sockets in a single process. You should create and use exactly one context in your process, if you create 2, these will be like separate ZMQ instances.

Instance Variables :
pointer : <aPointer>, points to a ZMQ Context
"
Class {
#name : #ZMQContext,
#superclass : #FFIExternalObject,
#pools : [
'ZMQConstants'
],
#category : #'ZMQ-Core'
}

{ #category : #'instance creation' }
ZMQContext class >> new [

^ self new: 1
]

{ #category : #'instance creation' }
ZMQContext class >> new: intIoThreads [

| context |
context := (ZMQInterface default ctxInit: intIoThreads).
^ context
]

{ #category : #dependencies }
ZMQContext >> destroy [

| ret |
handle ifNotNil: [ ret := ZMQInterface default ctxDestroy: handle ].
ret = -1 ifTrue: [
self error: 'ZMQ Context Error, unsuccessful destruction' ].
^ self
]

{ #category : #dependencies }
ZMQContext >> release [

self destroy
]
Loading
Loading