Skip to content

Commit

Permalink
Add lang.runtime module
Browse files Browse the repository at this point in the history
Functions to register and deregister a  listener.
Fixes #361.
  • Loading branch information
jclark committed Oct 30, 2020
1 parent e314099 commit 9b472c2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lang/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ ZIPFILE=$(DISTDIR).zip
COPYFILES= \
lib/array.bal lib/boolean.bal lib/decimal.bal lib/error.bal lib/float.bal \
lib/future.bal lib/int.bal lib/map.bal lib/object.bal lib/stream.bal \
lib/string.bal lib/table.bal lib/typedesc.bal lib/value.bal lib/xml.bal \
lib/string.bal lib/table.bal lib/typedesc.bal lib/xml.bal \
lib/runtime.bal lib/value.bal \
style/ballerina-language-specification.css \
style/ballerina-language-specification.js
DISTFILES=spec.html $(COPYFILES)
Expand Down
34 changes: 34 additions & 0 deletions lang/lib/runtime.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) 2020 WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
//
// WSO2 Inc. licenses this file to you under the Apache License,
// Version 2.0 (the "License"); you may not use this file except
// in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

# A listener that is dynamically registered with a module.
public type DynamicListener object {
public function 'start() returns error?;
public function gracefulStop() returns error?;
public function immedateStop() returns error?;
};

This comment has been minimized.

Copy link
@jclark

jclark Nov 2, 2020

Author Collaborator

There's no object:Listener type any more. There's an internal Listener<T> type instead. See #615. Listener<T> is a subtype of DynamicListener, so you don't need to implement two listeners.


# Register a listener object with a module.
# + listener - the listener object to be registered
# The listener becomes a module listener of the module from which this
# function is called.
public isolated function registerListener(DynamicListener listener) = external;

# Deregister a listener from a module.
# + listener - the listener object to be unregistered
# The `listener` ceases to be a module listener of the module from
# which this function is called.
public isolated function deregisterListener(DynamicListener listener) = external;
6 changes: 4 additions & 2 deletions lang/spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -9134,10 +9134,10 @@ <h2 id="lang_library">10. Lang library</h2>
</p>
<p>
The lang library comprises the following modules. With the exception of the
<code>lang.value</code> module, each corresponds to a basic type.
<code>lang.value</code> and <code>lang.runtime</code> modules, each corresponds
to a basic type.
</p>
<ul>
<li><code><a href="./lib/value.bal" type="text/plain">lang.value</a></code></li>
<li><code><a href="./lib/array.bal" type="text/plain">lang.array</a></code> for
basic type list</li>
<li><code><a href="./lib/boolean.bal" type="text/plain">lang.boolean</a></code> for
Expand Down Expand Up @@ -9166,6 +9166,8 @@ <h2 id="lang_library">10. Lang library</h2>
basic type typedesc</li>
<li><code><a href="./lib/xml.bal" type="text/plain">lang.xml</a></code> for
basic type xml</li>
<li><code><a href="./lib/runtime.bal" type="text/plain">lang.runtime</a></code></li>
<li><code><a href="./lib/value.bal" type="text/plain">lang.value</a></code></li>
</ul>
<p>
Modules in the lang library can make use generic typing. Since generic typing
Expand Down

0 comments on commit 9b472c2

Please sign in to comment.